test_encrypt_stream.py 630 B

12345678910111213141516171819
  1. from panda3d import core
  2. import pytest
  3. @pytest.mark.skipif(not hasattr(core, 'IDecryptStream'), reason="Requires OpenSSL")
  4. def test_decrypt_stream():
  5. encrypted = b'[\x00\x10\x00d\x00\x07K\x08\x03\xabS\x13L\xab\x93\x1b\x15\xe4\xeel\x80u o\xd0\x80aY_]\x10\x8a\xb5\xff\x9d1\xc9\xd3\xac\x95\x04\xd8\xdf\x10\xa1'
  6. decrypted = b'abcdefghijklmnopqrstuvwxyz'
  7. ss = core.StringStream(encrypted)
  8. ds = core.IDecryptStream(ss, False, '0123456789')
  9. assert ds.read(len(decrypted)) == decrypted
  10. assert ds.readall() == b''
  11. # Allow seeking back to the beginning
  12. ds.seekg(0)
  13. assert ds.readall() == decrypted