From: Leo U. <leo...@ya...> - 2005-09-16 17:59:48
|
Hi, I noticed some capitalisation differences in the output from md5 in jython and python. I don't know if its broken, but Im assuming that it is. A Jython session: Jython 2.2a1 on java1.5.0_02 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import md5 >>> a = md5.new() >>> a.digest() '\xD4\x1D\x8C\xD9\x8F\x00\xB2\x04\xE9\x80\t\x98\xEC\xF8B~' >>> a.update( "CAT" ) >>> a.digest() '\xC0\x1A\xE1\xA5\xF1"\xF2\\\xE5g_\x86\x02\x8BSj' >>> A Python session: C:\WINDOWS>python Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import md5 >>> a = md5.new() >>> a.digest() '\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\t\x98\xec\xf8B~' >>> a.update( "CAT" ) >>> a.digest() '\xc0\x1a\xe1\xa5\xf1"\xf2\\\xe5g_\x86\x02\x8bSj' >>> -------- notice how the digest returns the same letters but in some cases the capitalisation is different. Im assuming this is a bug, but maybe it is OK for md5 to do this... thought I find the chances of that being correct slim. leouser __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Jeff E. <jem...@fr...> - 2005-09-16 18:11:36
|
The 2 characters following \x are hexidecimal digits. Case doesn't matter. Leo User wrote: > Hi, > > I noticed some capitalisation differences in the output from md5 in jython and python. I don't know if its broken, but Im assuming that it is. > A Jython session: > Jython 2.2a1 on java1.5.0_02 (JIT: null) > Type "copyright", "credits" or "license" for more information. > >>>>import md5 >>>>a = md5.new() >>>>a.digest() > > '\xD4\x1D\x8C\xD9\x8F\x00\xB2\x04\xE9\x80\t\x98\xEC\xF8B~' > >>>>a.update( "CAT" ) >>>>a.digest() > > '\xC0\x1A\xE1\xA5\xF1"\xF2\\\xE5g_\x86\x02\x8BSj' > > > A Python session: > C:\WINDOWS>python > Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>>>import md5 >>>>a = md5.new() >>>>a.digest() > > '\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\t\x98\xec\xf8B~' > >>>>a.update( "CAT" ) >>>>a.digest() > > '\xc0\x1a\xe1\xa5\xf1"\xf2\\\xe5g_\x86\x02\x8bSj' > > > -------- > notice how the digest returns the same letters but in some cases the capitalisation is different. Im assuming this is a bug, but maybe it is OK for md5 to do this... thought I find the chances of that being correct slim. > > leouser > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com |
From: Kent J. <ke...@td...> - 2005-09-16 18:12:01
|
Leo User wrote: > Hi, > > I noticed some capitalisation differences in the output from md5 in > jython and python. I don't know if its broken, but Im assuming that it is. > A Jython session: > Jython 2.2a1 on java1.5.0_02 (JIT: null) > >>> a.digest() > '\xC0\x1A\xE1\xA5\xF1"\xF2\\\xE5g_\x86\x02\x8BSj' > >>> > > A Python session: > C:\WINDOWS>python > Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on > win32 > >>> a.digest() > '\xc0\x1a\xe1\xa5\xf1"\xf2\\\xe5g_\x86\x02\x8bSj' > >>> > > -------- > notice how the digest returns the same letters but in some cases the > capitalisation is different. This is just a difference in the repr() of the string - the letters are hex digits in \x escapes, not actually part of the hash itself. A plain string shows the same difference: Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> '\xab' '\xab' >>> ^Z Jython 2.2a1 on java1.4.2_06 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> '\xab' '\xAB' Arguably this is a bug in str.__repr__() but it is not a problem with the hash algorithm. Kent |
From: Leo U. <leo...@ya...> - 2005-09-16 19:05:04
|
this is most interesting. The real test for me is going to be whether or not the digest created in jython and stashed is going to be == to one created by python. We may be using md5 to test whether data has changed, and it needs to work in both environments. I somewhat suspect that it might given your comments here. thanks! leouser Kent Johnson <ke...@td...> wrote: Leo User wrote: > Hi, > > I noticed some capitalisation differences in the output from md5 in > jython and python. I don't know if its broken, but Im assuming that it is. > A Jython session: > Jython 2.2a1 on java1.5.0_02 (JIT: null) > >>> a.digest() > '\xC0\x1A\xE1\xA5\xF1"\xF2\\\xE5g_\x86\x02\x8BSj' > >>> > > A Python session: > C:\WINDOWS>python > Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on > win32 > >>> a.digest() > '\xc0\x1a\xe1\xa5\xf1"\xf2\\\xe5g_\x86\x02\x8bSj' > >>> > > -------- > notice how the digest returns the same letters but in some cases the > capitalisation is different. This is just a difference in the repr() of the string - the letters are hex digits in \x escapes, not actually part of the hash itself. A plain string shows the same difference: Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> '\xab' '\xab' >>> ^Z Jython 2.2a1 on java1.4.2_06 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> '\xab' '\xAB' Arguably this is a bug in str.__repr__() but it is not a problem with the hash algorithm. Kent ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ Jython-dev mailing list Jyt...@li... https://lists.sourceforge.net/lists/listinfo/jython-dev __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |