3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function encode($string,$key) { $key = sha1($key); $strLen = strlen($string); $keyLen = strlen($key); for ($i = 0; $i < $strLen; $i++) { $ordStr = ord(substr($string,$i,1)); if ($j == $keyLen) { $j = 0; } $ordKey = ord(substr($key,$j,1)); $j++; $hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36)); } return $hash; } function decode($string,$key) { $key = sha1($key); $strLen = strlen($string); $keyLen = strlen($key); for ($i = 0; $i < $strLen; $i+=2) { $ordStr = hexdec(base_convert(strrev(substr($string,$i,2)),36,16)); if ($j == $keyLen) { $j = 0; } $ordKey = ord(substr($key,$j,1)); $j++; $hash .= chr($ordStr - $ordKey); } return $hash; } echo encode("i:1:1",3029); echo decode(encode("i:1:1",3029),3029); ?>
Output for 5.0.4 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined variable: j in /in/bS29d on line 8 Notice: Undefined variable: j in /in/bS29d on line 9 Notice: Undefined variable: j in /in/bS29d on line 10 Notice: Undefined variable: hash in /in/bS29d on line 11 p533q273t2 Notice: Undefined variable: j in /in/bS29d on line 8 Notice: Undefined variable: j in /in/bS29d on line 9 Notice: Undefined variable: j in /in/bS29d on line 10 Notice: Undefined variable: hash in /in/bS29d on line 11 Notice: Undefined variable: j in /in/bS29d on line 22 Notice: Undefined variable: j in /in/bS29d on line 23 Notice: Undefined variable: j in /in/bS29d on line 24 Notice: Undefined variable: hash in /in/bS29d on line 25 i:1:1
Output for hhvm-3.12.0
Notice: Undefined variable: j in /in/bS29d on line 8 Notice: Undefined variable: j in /in/bS29d on line 9 Warning: substr() expects parameter 2 to be integer, null given in /in/bS29d on line 9 Warning: ord() expects parameter 1 to be string, null given in /in/bS29d on line 9 Notice: Undefined variable: j in /in/bS29d on line 10 x233q273t2 Notice: Undefined variable: j in /in/bS29d on line 8 Notice: Undefined variable: j in /in/bS29d on line 9 Warning: substr() expects parameter 2 to be integer, null given in /in/bS29d on line 9 Warning: ord() expects parameter 1 to be string, null given in /in/bS29d on line 9 Notice: Undefined variable: j in /in/bS29d on line 10 Notice: Undefined variable: j in /in/bS29d on line 22 Notice: Undefined variable: j in /in/bS29d on line 23 Warning: substr() expects parameter 2 to be integer, null given in /in/bS29d on line 23 Warning: ord() expects parameter 1 to be string, null given in /in/bS29d on line 23 Notice: Undefined variable: j in /in/bS29d on line 24 i:1:1
Output for hhvm-3.10.0
Notice: Undefined variable: j in /in/bS29d on line 8 Notice: Undefined variable: j in /in/bS29d on line 9 Notice: Undefined variable: j in /in/bS29d on line 10 p533q273t2 Notice: Undefined variable: j in /in/bS29d on line 8 Notice: Undefined variable: j in /in/bS29d on line 9 Notice: Undefined variable: j in /in/bS29d on line 10 Notice: Undefined variable: j in /in/bS29d on line 22 Notice: Undefined variable: j in /in/bS29d on line 23 Notice: Undefined variable: j in /in/bS29d on line 24 i:1:1
Output for 4.3.0 - 5.0.3
Notice: Undefined variable: j in /in/bS29d on line 8 Notice: Undefined variable: j in /in/bS29d on line 9 Notice: Undefined variable: j in /in/bS29d on line 10 Notice: Undefined variable: hash in /in/bS29d on line 11 p533q273t2 Notice: Undefined variable: j in /in/bS29d on line 8 Notice: Undefined variable: j in /in/bS29d on line 9 Notice: Undefined variable: j in /in/bS29d on line 10 Notice: Undefined variable: hash in /in/bS29d on line 11 Notice: Undefined variable: j in /in/bS29d on line 22 Notice: Undefined variable: j in /in/bS29d on line 23 Notice: Undefined variable: j in /in/bS29d on line 24 Notice: Undefined variable: hash in /in/bS29d on line 25 i:1:1