3v4l.org

run code in 300+ PHP versions simultaneously
<?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 git.master, git.master_jit, rfc.property-hooks
(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 Warning: Undefined array key 13 in /in/1RGrN on line 24 Deprecated: ord(): Passing null to parameter #1 ($character) of type string is deprecated in /in/1RGrN on line 24 Warning: Undefined array key 14 in /in/1RGrN on line 24 Deprecated: ord(): Passing null to parameter #1 ($character) of type string is deprecated in /in/1RGrN on line 24 (Keysize = 15) 2.93

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
39.33 ms | 402 KiB | 8 Q