<?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 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- (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
- Output for 8.0.0 - 8.0.30
- (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
Warning: Undefined array key 14 in /in/1RGrN on line 24
(Keysize = 15) 2.93
- Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
- (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 7.3.32 - 7.3.33, 7.4.26
- (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
(Keysize = 15) 2.93
- Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.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.3.11, 4.4.0 - 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
preferences:
300.7 ms | 401 KiB | 460 Q