Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php
  2. function enc($string) {
  3.   $stringLength = strlen($string);
  4.   $array;
  5.   $returnString = "";
  6.  
  7.   for($x = 0; $x < $stringLength; $x++) {
  8.     $array[$x] = ord($string{$x});
  9.     if ($x < $stringLength-1) {
  10.       $returnString .= $array[$x].",";
  11.     } else {
  12.       $returnString .= $array[$x];
  13.     }
  14.   }
  15.   return $returnString;
  16. }
  17.  
  18. function dec($hash) {
  19.   $hashLength = strlen($hash);
  20.   $returnString = "";
  21.  
  22.   $numberArray = explode(",", $hash);
  23.   for ($x = 0; $x < $hashLength; $x++) {
  24.     $returnString .= chr($numberArray[$x]);
  25.   }
  26.   return $returnString;
  27. }
  28.  
  29. $encryptedText = enc("hey");
  30. echo "Encrypted string: ".$encryptedText."<br />";
  31. echo "Decrypted string: ".dec($encryptedText)."<br />";
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement