Advertisement
Guest User

Untitled

a guest
Jun 24th, 2011
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1. <?php
  2.     $chars = stripslashes(rawurldecode ($_POST['chars']));
  3.     if($chars != "") {
  4.         $rot = intval((time()*1000)/(1000 * 60 * 5));
  5.        
  6.         $output = "";
  7.         for($i = 0; $i < strlen($chars); $i++ )
  8.         {
  9.             $char = ord(substr($chars, $i, 1)) - $rot;
  10.             while ($char < 0 )
  11.             $char += 255;
  12.             $output .= chr($char);
  13.         }
  14.        
  15.         print $output . "\n";
  16.         exit;
  17.     }
  18. ?>
  19.  
  20. <html>
  21. <body>
  22.  
  23. <script type="text/javascript">
  24. var rot = parseInt(new Date().getTime()/(1000 * 60 * 5));
  25.  
  26. var input = "This is a test";
  27. var output = "";
  28.  
  29. for(var i = 0; i < input.length; i++)
  30. {
  31.     char = ( input.charCodeAt(i) + rot ) %255;
  32.     output += String.fromCharCode(char);
  33. }
  34.  
  35. output = escape(output);
  36. console.log(output);
  37.  
  38. var http = new XMLHttpRequest();
  39.  
  40. var url = "test.php";
  41. var params = "chars="+output;
  42.  
  43.  
  44. http.open("POST", url, true);
  45.  
  46. //Send the proper header information along with the request
  47. http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  48.  
  49.  
  50. http.onreadystatechange = function() {//Call a function when the state changes.
  51.     if(http.readyState == 4 && http.status == 200) {
  52.         alert(http.responseText);
  53.     }
  54. }
  55. http.send(params);
  56.  
  57. </script>
  58.  
  59.  
  60. </body>
  61. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement