3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /* $string = 'This is my encrypted string!'; $key = 'KEY'; $split = str_split($string, 3); foreach($split as $chars) echo bin2hex($chars ^ $key); */ function hamdist($a, $b) { $a = str_split($a); $b = str_split($b); $len = count($a); $dist = 0; for($i = 0; $i < $len; $i++) { $bits['a'] = str_split(sprintf('%08d', decbin(ord($a[$i])))); $bits['b'] = str_split(sprintf('%08d', decbin(ord($b[$i])))); for($x = 0, $len2 = count($bits['a']); $x < $len2; $x++) if($bits['a'][$x] != $bits['b'][$x]) $dist++; } return $dist; } $enc = hex2bin('1f2d3038653038653432653c25262b32352d2e217938312b222b3e6a'); for($keysize = 2; $keysize <= 15; $keysize++) { $blockA = substr($enc, 0, $keysize); $blockB = substr($enc, $keysize, $keysize); printf("(Keysize = %d)\t%.2f\n", $keysize, (hamdist($blockA, $blockB) / $keysize)); }
Output for 5.4.0 - 5.6.28, 7.0.0 - 7.1.0
(Keysize = 2) 4.00 (Keysize = 3) 2.00 (Keysize = 4) 3.75 (Keysize = 5) 3.80 (Keysize = 6) 1.83 (Keysize = 7) 3.57 (Keysize = 8) 3.25 (Keysize = 9) 2.89 (Keysize = 10) 3.00 (Keysize = 11) 3.27 (Keysize = 12) 3.08 (Keysize = 13) 2.85 (Keysize = 14) 3.29 Notice: Undefined offset: 13 in /in/1RGrN on line 24 Notice: Undefined offset: 14 in /in/1RGrN on line 24 (Keysize = 15) 2.93
Output for hhvm-3.12.0
(Keysize = 2) 4.00 (Keysize = 3) 2.00 (Keysize = 4) 3.75 (Keysize = 5) 3.80 (Keysize = 6) 1.83 (Keysize = 7) 3.57 (Keysize = 8) 3.25 (Keysize = 9) 2.89 (Keysize = 10) 3.00 (Keysize = 11) 3.27 (Keysize = 12) 3.08 (Keysize = 13) 2.85 (Keysize = 14) 3.29 Notice: Undefined index: 13 in /in/1RGrN on line -1 Notice: Undefined index: 14 in /in/1RGrN on line -1 (Keysize = 15) 2.93
Output for hhvm-3.10.0
(Keysize = 2) 4.00 (Keysize = 3) 2.00 (Keysize = 4) 3.75 (Keysize = 5) 3.80 (Keysize = 6) 1.83 (Keysize = 7) 3.57 (Keysize = 8) 3.25 (Keysize = 9) 2.89 (Keysize = 10) 3.00 (Keysize = 11) 3.27 (Keysize = 12) 3.08 (Keysize = 13) 2.85 (Keysize = 14) 3.29 Notice: Undefined index: 13 in /in/1RGrN on line 24 Notice: Undefined index: 14 in /in/1RGrN on line 24 (Keysize = 15) 2.93
Output for 5.0.0 - 5.3.29
Fatal error: Call to undefined function hex2bin() in /in/1RGrN on line 34
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: hex2bin() in /in/1RGrN on line 34
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: hex2bin() in /in/1RGrN on line 34
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: hex2bin() in /in/1RGrN on line 34