Last active
February 24, 2017 10:37
-
-
Save artygrand/9e64915cfb8c7dc30ca503d9542bb175 to your computer and use it in GitHub Desktop.
Sample XOR encoder
This file contains 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 | |
$encoded = "..."; // <-- encoded string from the request | |
$decoded = ""; | |
for( $i = 0; $i < strlen($encoded); $i++ ) { | |
$b = ord($encoded[$i]); | |
$a = $b ^ 123; // <-- must be same number used to encode the character | |
$decoded .= chr($a) | |
} | |
echo $decoded; |
This file contains 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
<html> | |
<head><title>Encoder</title></head> | |
<body> | |
<script type="text/javascript"> | |
function enc(str) { | |
var encoded = ""; | |
for (i=0; i<str.length;i++) { | |
var a = str.charCodeAt(i); | |
var b = a ^ 123; // bitwise XOR with any number, e.g. 123 | |
encoded = encoded+String.fromCharCode(b); | |
} | |
return encoded; | |
} | |
var str = "hello world"; | |
var encoded = enc(str); | |
alert(encoded); // shows encoded string | |
alert(enc(encoded)); // shows the original string again | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment