Last active
August 8, 2016 11:12
-
-
Save polonskiy/9c5b78d57b1237de8945 to your computer and use it in GitHub Desktop.
Repeating-key XOR encryption
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 | |
$data = file_get_contents('php://stdin'); | |
$password = 'ps8T0G/39oHgRehuV0TjUv2lyeA='; | |
$c = rkxor($data, $password); | |
$x = rkxor($c, $password); | |
var_dump($c,$x); | |
function rkxor($data, $password) { | |
$key = md5($password, true); | |
$key_len = strlen($key); | |
$data_len = strlen($data); | |
$cipher = ''; | |
for ($i = 0; $i < $data_len; $i++) { | |
$cipher .= $data[$i] ^ $key[$i % $key_len]; | |
} | |
return $cipher; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment