006-secret_coder.py 719 B

12345678910111213141516171819202122232425262728293031323334
  1. import pathlib
  2. current = pathlib.Path(__file__).parent
  3. root = current.parent
  4. import sys
  5. sys.path.append(str(root))
  6. import assets
  7. crypter = assets.secret_coder("password")
  8. test_1 = crypter.encrypt("UwU")
  9. print("UwU crypted: " + test_1)
  10. print("\"" + test_1 + "\" decrypted: " + crypter.decrypt(test_1))
  11. print("")
  12. print("New crypted creating...")
  13. crypter = assets.secret_coder("password")
  14. print("\"" + test_1 + "\" decrypted: " + crypter.decrypt(test_1))
  15. print("")
  16. print("Testing with bad password...")
  17. crypter = assets.secret_coder("password 2")
  18. try:
  19. crypter.decrypt(test_1)
  20. print("Exception for bad password not working.")
  21. except assets.bad_password:
  22. print("Exception for bad password working.")