Encryption

there have a encryption practive tool I wrote via Rust, which contains a variety of encryption algorithms.

Encrypt toolarrow-up-right

XOR

XOR encryption is the simplest. It is a bidirectional encryption algorithm. It is also called a symmetric encryption algorithm. It is a reversible encryption algorithm. The same key is used for encryption and decryption. The key is a byte array. The key length is generally 8 bits, 16 bits, 32 bits, 64 bits, 128 bits, 256 bits, etc

typedef enum ENC_STATUS
{
	ENC_STATUS_ERROR,
	ENC_STATUS_SUCCESS,
	ENC_STATUS_INVALID_PARAMETER,

} ENC_STATUS;

ENC_STATUS WINAPI XorEncrypt(IN PBYTE pBuffer, IN SIZE_T sBufferSize, IN PBYTE key, IN SIZE_T sKeySize)
{
        if (pBuffer == NULL || key == NULL || sBufferSize == 0 || sKeySize == 0)
        {
                return ENC_STATUS_INVALID_PARAMETER;
        }

        for (SIZE_T i = 0; i < sBufferSize; i++)
        {
                pBuffer[i] ^= key[i % sKeySize];
        }

        return ENC_STATUS_SUCCESS;
}

Last updated