Advertisement
Guest User

Untitled

a guest
May 20th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1.  function encode($value){
  2. $key = sha1('EnCRypT10nK#Y!RiSRNn');
  3. if(!$value){return false;}
  4. $strLen = strlen($value);
  5. $keyLen = strlen($key);
  6. $j=0;
  7. $crypttext= '';
  8. for ($i = 0; $i < $strLen; $i++) {
  9. $ordStr = ord(substr($value,$i,1));
  10. if ($j == $keyLen) { $j = 0; }
  11. $ordKey = ord(substr($key,$j,1));
  12. $j++;
  13. $crypttext .= strrev(base_convert(dechex($ordStr + $ordKey),16,36));
  14. }
  15. return $crypttext;
  16.  
  17. }
  18.  
  19.  function decode($value){
  20.     if(!$value){return false;}
  21.         $key = sha1('EnCRypT10nK#Y!RiSRNn');
  22.         $strLen = strlen($value);
  23.         $keyLen = strlen($key);
  24.         $j=0;
  25.         $decrypttext= '';
  26.         for ($i = 0; $i < $strLen; $i+=2) {
  27.             $ordStr = hexdec(base_convert(strrev(substr($value,$i,2)),36,16));
  28.             if ($j == $keyLen) { $j = 0; }
  29.             $ordKey = ord(substr($key,$j,1));
  30.             $j++;
  31.             $decrypttext .= chr($ordStr - $ordKey);
  32.         }
  33.  
  34.     return $decrypttext;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement