test_encrypt.py 728 B

12345678910111213141516171819
  1. from panda3d import core
  2. def test_encrypt_string():
  3. # Test encrypt and then decrypt cycle
  4. for algorithm in ('', 'bf-cbc', 'aes-256-cbc'):
  5. enc = core.encrypt_string('abcdefg', '12345', algorithm)
  6. assert len(enc) > 0
  7. dec = core.decrypt_string(enc, '12345')
  8. assert dec == 'abcdefg'
  9. # Test pre-encrypted bf-cbc string
  10. enc = b'[\x00\x10\x00d\x00\xb5\x7f\xc44Y\xb7\xd9\x15\xe3\xbd\xcf\xb3yK\xfb\xf6'
  11. assert 'test' == core.decrypt_string(enc, '98765')
  12. # Test pre-encrypted aes-256-cbc string
  13. enc = b'\xab\x01 \x00d\x00\xf1WP\xb0\x96h\xf8\xc5\xf4\x8d\x0b>q0\xf15\x185\xf8+\x1b\xe4\xae8\x88\xf2\x91\x15\xb8\x8fh\x88'
  14. assert 'test' == core.decrypt_string(enc, '98765')