-
-
Save masak/643769 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.elliottkember.com/kember_identity.html | |
use v6; | |
pir::load_bytecode('Digest/MD5.pir'); | |
my Int $count = 0; | |
my Str @alphabet = (0..9, 'a'..'f'); | |
my Str $string = @alphabet.roll(32).join; | |
loop { | |
my Str $md5 = md5_hex($string); | |
if ($md5 === $string) { | |
say "We have a winner after testing $count strings!"; | |
say "md5($string) = $md5"; | |
exit; | |
} | |
if ((++$count % 10) === 0) { | |
say "{$count/10}: md5($string) = $md5"; | |
} | |
$string = $md5; | |
} | |
sub md5_hex (Str $str) { | |
return Q:PIR { | |
.local pmc f, g, str | |
str = find_lex '$str' | |
f = get_root_global ['parrot'; 'Digest'], '_md5sum' | |
$P1 = f(str) | |
g = get_root_global ['parrot'; 'Digest'], '_md5_hex' | |
$S0 = g($P1) | |
%r = box $S0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment