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("Please Encode Me!","This is a key"); echo decode(encode("Please Encode Me!","This is a key")); ?>
Output for 7.1.0
Notice: Undefined variable: j in /in/dOYvL on line 8 Notice: Undefined variable: j in /in/dOYvL on line 9 Notice: Undefined variable: j in /in/dOYvL on line 10 Notice: Undefined variable: hash in /in/dOYvL on line 11 p3e4e4241674d2r4m4i5o464a4f2p3k5c2 Notice: Undefined variable: j in /in/dOYvL on line 8 Notice: Undefined variable: j in /in/dOYvL on line 9 Notice: Undefined variable: j in /in/dOYvL on line 10 Notice: Undefined variable: hash in /in/dOYvL on line 11 Fatal error: Uncaught ArgumentCountError: Too few arguments to function decode(), 1 passed in /in/dOYvL on line 30 and exactly 2 expected in /in/dOYvL:16 Stack trace: #0 /in/dOYvL(30): decode('p3e4e4241674d2r...') #1 {main} thrown in /in/dOYvL on line 16
Process exited with code 255.
Output for 5.1.0 - 5.6.28, 7.0.0 - 7.0.14
Notice: Undefined variable: j in /in/dOYvL on line 8 Notice: Undefined variable: j in /in/dOYvL on line 9 Notice: Undefined variable: j in /in/dOYvL on line 10 Notice: Undefined variable: hash in /in/dOYvL on line 11 p3e4e4241674d2r4m4i5o464a4f2p3k5c2 Notice: Undefined variable: j in /in/dOYvL on line 8 Notice: Undefined variable: j in /in/dOYvL on line 9 Notice: Undefined variable: j in /in/dOYvL on line 10 Notice: Undefined variable: hash in /in/dOYvL on line 11 Warning: Missing argument 2 for decode(), called in /in/dOYvL on line 30 and defined in /in/dOYvL on line 16 Notice: Undefined variable: key in /in/dOYvL on line 17 Notice: Undefined variable: j in /in/dOYvL on line 22 Notice: Undefined variable: j in /in/dOYvL on line 23 Notice: Undefined variable: j in /in/dOYvL on line 24 Notice: Undefined variable: hash in /in/dOYvL on line 25 !=kYxd�Fqar4f�Ud!
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined variable: j in /in/dOYvL on line 8 Notice: Undefined variable: j in /in/dOYvL on line 9 Notice: Undefined variable: j in /in/dOYvL on line 10 p3e4e4241674d2r4m4i5o464a4f2p3k5c2 Notice: Undefined variable: j in /in/dOYvL on line 8 Notice: Undefined variable: j in /in/dOYvL on line 9 Notice: Undefined variable: j in /in/dOYvL on line 10 Warning: decode() expects exactly 2 parameters, 1 given in /in/dOYvL on line 17 Notice: Undefined variable: key in /in/dOYvL on line 17 Notice: Undefined variable: j in /in/dOYvL on line 22 Notice: Undefined variable: j in /in/dOYvL on line 23 Notice: Undefined variable: j in /in/dOYvL on line 24 !=kYxd�Fqar4f�Ud!
Output for 5.0.4 - 5.0.5
Notice: Undefined variable: j in /in/dOYvL on line 8 Notice: Undefined variable: j in /in/dOYvL on line 9 Notice: Undefined variable: j in /in/dOYvL on line 10 Notice: Undefined variable: hash in /in/dOYvL on line 11 p3e4e4241674d2r4m4i5o464a4f2p3k5c2 Notice: Undefined variable: j in /in/dOYvL on line 8 Notice: Undefined variable: j in /in/dOYvL on line 9 Notice: Undefined variable: j in /in/dOYvL on line 10 Notice: Undefined variable: hash in /in/dOYvL on line 11 Warning: Missing argument 2 for decode() in /in/dOYvL on line 16 Notice: Undefined variable: j in /in/dOYvL on line 22 Notice: Undefined variable: j in /in/dOYvL on line 23 Notice: Undefined variable: j in /in/dOYvL on line 24 Notice: Undefined variable: hash in /in/dOYvL on line 25 !=kYxd�Fqar4f�Ud!
Output for 4.3.0 - 5.0.3
Notice: Undefined variable: j in /in/dOYvL on line 8 Notice: Undefined variable: j in /in/dOYvL on line 9 Notice: Undefined variable: j in /in/dOYvL on line 10 Notice: Undefined variable: hash in /in/dOYvL on line 11 p3e4e4241674d2r4m4i5o464a4f2p3k5c2 Notice: Undefined variable: j in /in/dOYvL on line 8 Notice: Undefined variable: j in /in/dOYvL on line 9 Notice: Undefined variable: j in /in/dOYvL on line 10 Notice: Undefined variable: hash in /in/dOYvL on line 11 Warning: Missing argument 2 for decode() in /in/dOYvL on line 16 Notice: Undefined variable: j in /in/dOYvL on line 22 Notice: Undefined variable: j in /in/dOYvL on line 23 Notice: Undefined variable: j in /in/dOYvL on line 24 Notice: Undefined variable: hash in /in/dOYvL on line 25 !=kYxd�Fqar4f�Ud!