feat: add PHP implementation

This commit is contained in:
Sean 2018-08-30 16:54:03 -07:00
parent 85d0688955
commit 93c250f6e8
1 changed files with 18 additions and 0 deletions

18
PHP/XOREncryption.php Normal file
View File

@ -0,0 +1,18 @@
<?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";