<?php
$chars = stripslashes(rawurldecode ($_POST['chars']));
if($chars != "") {
$rot = intval((time()*1000)/(1000 * 60 * 5));
$output = "";
for($i = 0; $i < strlen($chars); $i++ )
{
$char = ord(substr($chars, $i, 1)) - $rot;
while ($char < 0 )
$char += 255;
$output .= chr($char);
}
print $output . "\n";
exit;
}
?>
<html>
<body>
<script type="text/javascript">
var rot = parseInt(new Date().getTime()/(1000 * 60 * 5));
var input = "This is a test";
var output = "";
for(var i = 0; i < input.length; i++)
{
char = ( input.charCodeAt(i) + rot ) %255;
output += String.fromCharCode(char);
}
output = escape(output);
console.log(output);
var http = new XMLHttpRequest();
var url = "test.php";
var params = "chars="+output;
http.open("POST", url, true);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(params);
</script>
</body>
</html>