I am trying to find the pseudocode for the XOR encryption algorithm. However I've had no luck so far. Anybody know where I can find it?
EDIT: XOR 32 if that helps
EDIT 2: For Passwords
I am trying to find the pseudocode for the XOR encryption algorithm. However I've had no luck so far. Anybody know where I can find it?
EDIT: XOR 32 if that helps
EDIT 2: For Passwords
The most basic "xor encryption algorithm" is probably one that just XOR's the plaintext with the key, like so:
for each bit of the plaintext:
ciphertext = bit of plaintext XOR bit of key
where the key just wraps around when it reaches the end.
Since XOR is its own inverse, XORing the ciphertext with the key again in the same fashion will reveal the plaintext.
For C:
void crypt(char key, char *msg, size_t l)
{
int i;
for(i=0; i<l; i++)
msg[i]^=key;
}
void decrypt(char key, char *msg, size_t l)
{
crypt(key, msg, l);
}
Assuming you mean a Vernam cipher, it's just:
for i = 0 to length of input
output[i] = input[i] xor key[i mod key_length]
Note that this is quite weak unless the key-stream is at least as long as the input, and is never re-used.