#!/usr/bin/perl -w
# chaining hash for blosxthis.pl

use Digest::MD5 qw(md5 md5_hex md5_base64);

($secret, $top,$cfile)=@ARGV;
unless ($top) {
print "Usage: buildhash secret #hashes [/path/to/countfile]\n";
exit;
}

for ($x=0;$x<$top; $x++) {
 if (($x % 10) eq 0){ print "\n";}
 $secret=md5_hex($secret);
 $secret =~ /^(.{4})/;
 print "$1  ";
}

print "\n\n\n";
if ($cfile){
 open (C,"> $cfile") or die "can't open count file ";
 print C "$x\n";
} else {
print "Didn't write out a countfile. Remember to create one by hand\n";
}
