[IronPython] MD5 file checksum comparisons perform differently in different IPy versions?

Lukáš Duběda loocas at duber.cz
Thu Mar 24 22:34:16 CET 2011


Hi there everyone,

can anyone enlighten me, please, as to why does
a direct comparison of two MD5 checksums (completely
the same) result in a different output in IPy versions
prior to 2.7?

In both 2.6 and 2.6.1 when I make a MD5 checksum of
two files that were copied from the same source, I get:

FALSE

but if I run exactly the same code and compare the checksums
in IPy 2.7, I'm getting

TRUE

Here's the snippet:

try:
	srcFStream = FileStream(file1, FileMode.Open, FileAccess.Read)
	destFStream = FileStream(file2, FileMode.Open, FileAccess.Read)
	srcMD5 = md5.ComputeHash(srcFStream)
	destMD5 = md5.ComputeHash(destFStream)
except Exception as inst:
	print 'An exception occured:', inst
	return False
finally:
	srcFStream.Close()
	destFStream.Close()

print 'checksum comparison for files {0} {1} was {2}'.format(file1, 
file2, repr(srcMD5 == destMD5))
print 'last write time for file {0} was {1}'.format(file1, 
File.GetLastWriteTime(file1))
		print 'last write time for file {0} was {1}'.format(file2, 
File.GetLastWriteTime(file2))

In IPy prior to 2.7, I'm getting:

checksum comparison for files C:\Test\aabb.txt C:\Blabla\aabb.txt was False
last write time for file C:\Test\aabb.txt was 24.3.2011 20:53:05
last write time for file C:\Blabla\aabb.txt was 24.3.2011 20:53:05

Here are the checksums:
 >>> System.BitConverter.ToString(destMD5)
'2A-74-7D-5F-CC-FD-B6-75-57-C0-30-28-E4-BB-A4-0C'
 >>> System.BitConverter.ToString(srcMD5)
'2A-74-7D-5F-CC-FD-B6-75-57-C0-30-28-E4-BB-A4-0C'

Why is that? And how can I make sure of backwards compatibility?

Thanks a lot in advance, cheers,

-- 
Lukáš Duběda
Director
[T] +420 602 444 164

duber studio(tm)
[M] info at duber.cz
[W] http://www.duber.cz

[A] R.A.Dvorského 601, Praha 10
[A] 10900, Czech Republic, Europe



More information about the Ironpython-users mailing list