Merge pull request #15 from AlbinoDrought/master

Add PHP Implementation
This commit is contained in:
Kyle Banks 2019-01-10 10:19:04 -05:00 committed by GitHub
commit cfcfb0838c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 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";

View File

@ -14,6 +14,7 @@ Simple implementation of XOR Encryption/Decrypting in various languages, includi
- [JavaScript \(Node.js Compatible\)](JavaScript/XOREncryption.js)
- [Kotlin](Kotlin/XOREncryption.kt)
- [Objective-C](Objective-C/main.m)
- [PHP](PHP/XOREncryption.php)
- [Python](Python/XOREncryption.py)
- [Ruby](Ruby/xor.rb)
- [Swift](Swift/XOREncryption.swift)