Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 02-04-2007, 02:10 AM   #1 (permalink)
 
True Techie

Join Date: May 2006

Posts: 101

jonmon6691

Default Perl problems

I am trying to write a quick script that reads MD5 sums from a file then trys matching those sums to sums of the numbers 1 - infinity until a collision is found. But the program doesn't work for some reason, it only finds the collisions on some of the sums and most of the ones that it does are wrong. Is there anything in the coding that you see wrong that I'm just missing?

Code:
#Sets up MD5
use Digest::MD5;

#File to get the sums
$hash_file = "md5_sums.txt";

#Read the lines into an array
open (INFO,$hash_file);
	@hashes = <INFO>;
close INFO;

#Print what we got from the file (for debugging)
print @hashes;
print "\n";

#start a new hash object
$md5 = Digest::MD5->new;

#Main loop to go through every hash in the array
foreach $hash (@hashes)
{
	#Print what hash it is reading (for debugging)
	print "I'm on $hash";
	#Set the index to 0
	$i = 0;
	#iterate through the numbers until there is a match
	while ($digest != $hash)
	{
		#create a hash out of the number
		$md5->add($i);
		$digest = $md5->hexdigest;
		#if the the test hash is equal to the unknown then tell us
		if ($digest == $hash)
		{
			print "$digest is $i\n";
		}
		#increment i
		$i++;
	}
}
all of the sums that i am trying to break are numbers.
__________________
<small>
.:HP Pavillion dv6000:.
1.8 ghtz Intel Core 2 Duo
2GB RAM
120 GB HDD
nVidia Go graphics
Apache 2.2 (looking for a domain name)
</small>
jonmon6691 is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On