<?php
/**
* XOR Encryption Functions
* Created by: Joshua H. (TRUSTAbyss)
*
* Usage: xor_encrypt(string, key) to Encrypt the string
* or xor_decrypt(string, key) to decrypt the string.
*/
function xor_encrypt($string, $key)
{
for ($a=
0;
$a <
strlen($string);
$a++
) {
for ($b=
0;
$b <
strlen($key);
$b++
) {
$string[$a] = $string[$a]^$key[$b];
}
}
return $string;
}
function xor_decrypt($string, $key)
{
for ($a=
0;
$a <
strlen($string);
$a++
) {
for ($b=
0;
$b <
strlen($key);
$b++
) {
$string[$a] = $key[$b]^$string[$a];
}
}
return $string;
}
// Here's an example on using these functions.
//
// Use the name of the key to decrypt the string that was encrypted, using
// the xor_decrypt() function.
echo xor_encrypt
("I'm going to be encrypted!",
"keyName");
?>