[mod_python] odd behaviour of the md5-module in modpy

Jim Gallacher jpg at jgassociates.ca
Mon Jun 26 14:39:19 EDT 2006


Nikolaus Schlemm wrote:
> "Deron Meranda" <deron.meranda at gmail.com> responded offlist:
>> What version of python do you have, and what version of
>> mod_python?  Can you provide an simple example of how
>> you're importing the module and calling it?
> 
> i'm using python 2.4.3-1ubuntu1 and libapache2-mod-python-3.1.4-0ubuntu1 on my 
> ubuntu box and python 2.3.5-11 and libapache2-mod-python-3.2.8-1 on debian.
> 
> tested both with the following snippet:
> 
>     from mod_python import apache 
>  
>     # from http://www.ietf.org/rfc/rfc1321.txt
>     MD5_TESTS = { 
>         "": "d41d8cd98f00b204e9800998ecf8427e", 
>         "a": "0cc175b9c0f1b6a831c399e269772661", 
>         "abc": "900150983cd24fb0d6963f7d28e17f72", 
>         "message digest": "f96b697d7cb7938d525a2f31aaf161d0", 
>         "abcdefghijklmnopqrstuvwxyz": "c3fcd3d76192e4007dfb496cca67e13b", 
>         "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789": "d174ab98d277d9f5a5611c2c9f419d9f", 
>         "12345678901234567890123456789012345678901234567890123456789012345678901234567890": "57edf4a22be3c955ac49da2e2107b67a" 
>     } 
>  
>     def handler(req): 
>         import md5 
>         req.content_type = 'text/plain' 
>         req.write('md5: %s\n' % md5.__file__) 
>         for k, v in MD5_TESTS.items(): 
>             m = md5.new(k).hexdigest() 
>             req.write('"%s" -> "%s" ? %s\n' % (k, m, (m == v)))  
>         return apache.OK 
> 
> which e.g. leads to:
> 
>     md5: /usr/lib/python2.4/lib-dynload/md5.so
>     "" -> "0000000000000000d09215a3e97561b3" ? False
>     "a" -> "0000000000000000d09215a3e97561b3" ? False
>     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" -> "0000000000000000d09215a3e97561b3" ? 
> False
>     "12345678901234567890123456789012345678901234567890123456789012345678901234567890" -> "0000000000000000d09215a3e97561b3" ? 
> False
>     "message digest" -> "0000000000000000d09215a3e97561b3" ? False
>     "abc" -> "0000000000000000d09215a3e97561b3" ? False
>     "abcdefghijklmnopqrstuvwxyz" -> "0000000000000000d09215a3e97561b3" ? False
> 

Running your test script on Ubuntu 6.06  (Apache/2.0.55 (Ubuntu)
mod_python/3.3.0-dev-20060520 Python/2.4.3) I get:

md5: /usr/lib/python2.4/lib-dynload/md5.so
"" -> "d41d8cd98f00b204e9800998ecf8427e" ? True
"a" -> "0cc175b9c0f1b6a831c399e269772661" ? True
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ->
"d174ab98d277d9f5a5611c2c9f419d9f" ? True
"12345678901234567890123456789012345678901234567890123456789012345678901234567890"
-> "57edf4a22be3c955ac49da2e2107b67a" ? True
"message digest" -> "f96b697d7cb7938d525a2f31aaf161d0" ? True
"abc" -> "900150983cd24fb0d6963f7d28e17f72" ? True
"abcdefghijklmnopqrstuvwxyz" -> "c3fcd3d76192e4007dfb496cca67e13b" ? True


Beyond that, I don't know what to say.

Jim



More information about the Mod_python mailing list