0001 # Testing sha module (NIST's Secure Hash Algorithm) 0002 0003 # use the three examples from Federal Information Processing Standards 0004 # Publication 180-1, Secure Hash Standard, 1995 April 17 0005 # http://www.itl.nist.gov/div897/pubs/fip180-1.htm 0006 0007 import sha 0008 import unittest 0009 from test import test_support 0010 0011 0012 class SHATestCase(unittest.TestCase): 0013 def check(self, data, digest): 0014 computed = sha.new(data).hexdigest() 0015 self.assert_(computed == digest) 0016 0017 def test_case_1(self): 0018 self.check("abc", 0019 "a9993e364706816aba3e25717850c26c9cd0d89d") 0020 0021 def test_case_2(self): 0022 self.check("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 0023 "84983e441c3bd26ebaae4aa1f95129e5e54670f1") 0024 0025 def test_case_3(self): 0026 self.check("a" * 1000000, 0027 "34aa973cd4c4daa4f61eeb2bdbad27316534016f") 0028 0029 0030 def test_main(): 0031 test_support.run_unittest(SHATestCase) 0032 0033 0034 if __name__ == "__main__": 0035 test_main() 0036
Generated by PyXR 0.9.4