Skip to content

Instantly share code, notes, and snippets.

Created October 24, 2010 17:59
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/643748 to your computer and use it in GitHub Desktop.
Perl 6 entry to find a MD5 fixpoint. (Requires Rakudo 2010-10)
#!/usr/bin/env perl6
# http://www.elliottkember.com/kember_identity.html
# Kudos to tadzik++ and masak++ on #perl6 for suggestions!
use v6;
use Digest::MD5; # Bundled as part of Rakudo Star 2010-10 release;
# also available as "neutro perl6-digest-md5"
my Int $count = 0;
my Str @alphabet = (0..9, 'a'..'f');
my Str $string = @alphabet.roll(32).join;
loop {
my Str $md5 = Digest::MD5.md5_hex($string);
if $md5 eq $string {
say "We have a winner after testing $count strings!";
say "md5($string) = $md5";
exit;
}
if ++$count %% 100 {
say "$count: md5($string) = $md5";
}
$string = $md5;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment