Created
March 18, 2016 13:02
-
-
Save AndyNovo/fdff34d0f4976e842358 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function xorIt($charOne, $charTwo) | |
{ | |
return $charOne ^ $charTwo; | |
} | |
function asciiValue($char) | |
{ | |
return ord($char); | |
} | |
function encrypt($plainText) | |
{ | |
$length = strlen($plainText); | |
$space = 0xA; | |
$cipherText = ""; | |
for ($i = 0; $i < $length; $i++) { | |
if ($i + $space < $length - 1) { | |
$cipherText .= xorIt($plainText[$i], $plainText[$i + $space]); | |
} else { | |
$cipherText .= xorIt($plainText[$i], $plainText[$space]); | |
} | |
$space = (asciiValue($plainText[$i]) % 2 == 0 ? $space + 1 : $space - 1); | |
} | |
return bin2hex($cipherText); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment