01-27-2012, 11:34 AM
Code:
#!/usr/bin/env perl
use strict;
use warnings;
use Digest::SHA qw (sha1_hex);
my $max = 99999999;
my $target = $ARGV[0] or die ("usage: $0 hash\n");
for (my $i = 0; $i < $max; $i++)
{
printf ("%4.1f%%\n", ($i / $max) * 100) if (($i % 100000) == 0);
my $plain = sprintf ("%08d\0\0\0\0\0\0\0\0", $i);
my $hash = sha1_hex ($plain);
if ($hash eq $target)
{
print $i, "\n";
exit;
}
}