mirror of
https://github.com/KyleBanks/XOREncryption.git
synced 2023-08-10 21:13:15 +03:00
19 lines
426 B
PHP
19 lines
426 B
PHP
<?php
|
|
|
|
function encryptDecrypt($input) {
|
|
$key = ['K', 'C', 'Q']; //Can be any chars, and any size array
|
|
$output = '';
|
|
|
|
for ($i = 0; $i < strlen($input); $i++) {
|
|
$output .= $input[$i] ^ $key[$i % count($key)];
|
|
}
|
|
return $output;
|
|
}
|
|
|
|
$encrypted = encryptDecrypt('kylewbanks.com');
|
|
echo "Encrypted:" . $encrypted . "\n";
|
|
|
|
$decrypted = encryptDecrypt($encrypted);
|
|
echo "Decrypted:" . $decrypted . "\n";
|
|
|