Simple XOR encryption

Simple XOR encryption, 9.3 out of 10 based on 4 ratings
VN:F [1.9.22_1171]
Rating: 9.3/10 (4 votes cast)

To protect your code against wannabee hackers you shouldn’t write anything important in clear text. Encrypt it and decrypt it again using bit flip also called XOR.

Sample Codes:

C++:

for(int i = 0, y = 0; i <= strlen(data); ) {
for(int o = 0; o <= BLOCK_SIZE; o++) {
if(data[i] != ”) {
data[i] ^= key[y]; }
i++; }
y++;
if(key[y] == ”) {
y = 0; }
}

PHP:

//encrypt
$s = ‘hello’;
$t = ”;
$z = ”;

for ($i=0; $i<5; $i++) {
$b ^= $s[$i];
$t .= $b;
}

// Decrypt
for ($i=0; $i<5; $i++) {
$b ^= $t[$i];
$z .= $b;
}

print($z);

This entry was posted in Allgemein. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *