mirror of
https://github.com/KyleBanks/XOREncryption.git
synced 2023-08-10 21:13:15 +03:00
23 lines
479 B
PHP
23 lines
479 B
PHP
<?php
|
|
|
|
function encryptDecrypt($input) {
|
|
$key = 'KCQ';
|
|
$inputLen = strlen($input);
|
|
$keyLen = strlen($key);
|
|
|
|
if ($inputLen <= $keyLen) {
|
|
return $input ^ $key;
|
|
}
|
|
|
|
for ($i = 0; $i < $inputLen; ++$i) {
|
|
$input[$i] = $input[$i] ^ $key[$i % $keyLen];
|
|
}
|
|
return $input;
|
|
}
|
|
|
|
$encrypted = encryptDecrypt('kylewbanks.com');
|
|
echo "Encrypted:" . $encrypted . "\n";
|
|
|
|
$decrypted = encryptDecrypt($encrypted);
|
|
echo "Decrypted:" . $decrypted . "\n";
|