mirror of
https://github.com/KyleBanks/XOREncryption.git
synced 2023-08-10 21:13:15 +03:00
feat: add PHP implementation
This commit is contained in:
parent
85d0688955
commit
93c250f6e8
18
PHP/XOREncryption.php
Normal file
18
PHP/XOREncryption.php
Normal 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";
|
||||
|
Loading…
Reference in New Issue
Block a user