test_win32crypt.py 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. # Test module for win32crypt
  2. import unittest
  3. import win32crypt
  4. from pywin32_testutil import str2bytes # py3k-friendly helper
  5. class Crypt(unittest.TestCase):
  6. def testSimple(self):
  7. data = str2bytes("My test data")
  8. entropy = None
  9. desc = "My description"
  10. flags = 0
  11. ps = None
  12. blob = win32crypt.CryptProtectData(data, desc, entropy, None, ps, flags)
  13. got_desc, got_data = win32crypt.CryptUnprotectData(blob, entropy, None, ps, flags)
  14. self.failUnlessEqual(data, got_data)
  15. self.failUnlessEqual(desc, got_desc)
  16. def testEntropy(self):
  17. data = str2bytes("My test data")
  18. entropy = str2bytes("My test entropy")
  19. desc = "My description"
  20. flags = 0
  21. ps = None
  22. blob = win32crypt.CryptProtectData(data, desc, entropy, None, ps, flags)
  23. got_desc, got_data = win32crypt.CryptUnprotectData(blob, entropy, None, ps, flags)
  24. self.failUnlessEqual(data, got_data)
  25. self.failUnlessEqual(desc, got_desc)
  26. if __name__ == '__main__':
  27. unittest.main()