Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function enc($string) {
- $stringLength = strlen($string);
- $array;
- $returnString = "";
- for($x = 0; $x < $stringLength; $x++) {
- $array[$x] = ord($string{$x});
- if ($x < $stringLength-1) {
- $returnString .= $array[$x].",";
- } else {
- $returnString .= $array[$x];
- }
- }
- return $returnString;
- }
- function dec($hash) {
- $hashLength = strlen($hash);
- $returnString = "";
- $numberArray = explode(",", $hash);
- for ($x = 0; $x < $hashLength; $x++) {
- $returnString .= chr($numberArray[$x]);
- }
- return $returnString;
- }
- $encryptedText = enc("hey");
- echo "Encrypted string: ".$encryptedText."<br />";
- echo "Decrypted string: ".dec($encryptedText)."<br />";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement