2018-08-31 02:54:03 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function encryptDecrypt($input) {
|
2020-08-17 05:52:27 +03:00
|
|
|
$key = 'KCQ';
|
|
|
|
$inputLen = strlen($input);
|
|
|
|
$keyLen = strlen($key);
|
2018-08-31 02:54:03 +03:00
|
|
|
|
2020-08-17 05:52:27 +03:00
|
|
|
if ($inputLen <= $keyLen) {
|
|
|
|
return $input ^ $key;
|
2018-08-31 02:54:03 +03:00
|
|
|
}
|
2020-08-17 05:52:27 +03:00
|
|
|
|
|
|
|
for ($i = 0; $i < $inputLen; ++$i) {
|
|
|
|
$input[$i] = $input[$i] ^ $key[$i % $keyLen];
|
|
|
|
}
|
|
|
|
return $input;
|
2018-08-31 02:54:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$encrypted = encryptDecrypt('kylewbanks.com');
|
|
|
|
echo "Encrypted:" . $encrypted . "\n";
|
|
|
|
|
|
|
|
$decrypted = encryptDecrypt($encrypted);
|
|
|
|
echo "Decrypted:" . $decrypted . "\n";
|