010-container-blob.py 823 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import asyncio
  2. import sys
  3. import pathlib
  4. import os
  5. test_file = pathlib.Path(__file__)
  6. project = test_file.parent.parent
  7. sys.path.append(str(project))
  8. import server_source as source
  9. from test import test
  10. async def main():
  11. text = "This is sample encrypted text."
  12. print("Encoding text: ")
  13. print("\"" + text + "\"")
  14. encrypted = await source.decoded(text).encode()
  15. print("Encoded: ")
  16. print("\"" + str(encrypted) + "\"")
  17. decrypted = await encrypted.decode()
  18. test(text, str(decrypted))
  19. print("Testing on random bytes...")
  20. blob = os.urandom(1024 * 1024 * 100)
  21. encrypted_blob = await source.decoded(blob).encode()
  22. print("Encrypted. Decrypting...")
  23. decrypted_blob = await encrypted_blob.decode()
  24. test(blob, bytes(decrypted_blob))
  25. asyncio.run(main())