3 warnings
.filterwarnings("ignore", "the md5 module is deprecated.*",
8 from test
import test_support
16 r
= r
+ h
[(i
>> 4) & 0xF] + h
[i
& 0xF]
19 class MD5_Test(unittest
.TestCase
):
21 def md5test(self
, s
, expected
):
22 self
.assertEqual(hexstr(md5(s
).digest()), expected
)
23 self
.assertEqual(md5(s
).hexdigest(), expected
)
25 def test_basics(self
):
27 eq('', 'd41d8cd98f00b204e9800998ecf8427e')
28 eq('a', '0cc175b9c0f1b6a831c399e269772661')
29 eq('abc', '900150983cd24fb0d6963f7d28e17f72')
30 eq('message digest', 'f96b697d7cb7938d525a2f31aaf161d0')
31 eq('abcdefghijklmnopqrstuvwxyz', 'c3fcd3d76192e4007dfb496cca67e13b')
32 eq('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
33 'd174ab98d277d9f5a5611c2c9f419d9f')
34 eq('12345678901234567890123456789012345678901234567890123456789012345678901234567890',
35 '57edf4a22be3c955ac49da2e2107b67a')
37 def test_hexdigest(self
):
38 # hexdigest is new with Python 2.0
39 m
= md5('testing the hexdigest method')
41 self
.assertEqual(hexstr(m
.digest()), h
)
43 def test_large_update(self
):
54 m2
.update(aas
+ bees
+ cees
)
55 self
.assertEqual(m1
.digest(), m2
.digest())
58 test_support
.run_unittest(MD5_Test
)
60 if __name__
== '__main__':