test_sm3_hash.py 589 B

123456789101112131415161718
  1. import unittest
  2. from fate_crypto.hash import sm3_hash
  3. class TestCorrect(unittest.TestCase):
  4. def test_hash_1(self):
  5. data = b"abc"
  6. expected = "66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0"
  7. self.assertEqual(sm3_hash(data).hex(), expected)
  8. def test_hash_2(self):
  9. data = b"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd"
  10. expected = "debe9ff92275b8a138604889c18e5a4d6fdb70e5387e5765293dcba39c0c5732"
  11. self.assertEqual(sm3_hash(data).hex(), expected)
  12. if __name__ == "__main__":
  13. unittest.main()