| 45 | |
| 46 | |
| 47 | def main(): |
| 48 | print("\t\tAES 256 Encryption and Decryption Algorithm") |
| 49 | print("\t\t-------------------------------------------\n\n") |
| 50 | x = input("Enter 1 to encrypt and 2 to decrypt: ") |
| 51 | if x == "1": |
| 52 | password = input("Enter the Password: ") |
| 53 | secret_mssg = input("\nEnter the Secret Message: ") |
| 54 | |
| 55 | # First, let us encrypt the secret message |
| 56 | encrypted = encrypt(secret_mssg, password) |
| 57 | print("\n\nEncrypted:") |
| 58 | print("---------------\n") |
| 59 | for k, v in encrypted.items(): |
| 60 | print(f"{k}: {v}") |
| 61 | |
| 62 | elif x == "2": |
| 63 | try: |
| 64 | encrypted = {} |
| 65 | encrypted["cipher_text"] = input("Enter the cipher text: ") |
| 66 | encrypted["salt"] = input("Enter the salt: ") |
| 67 | encrypted["nonce"] = input("Enter the nonce: ") |
| 68 | encrypted["tag"] = input("Enter the tag: ") |
| 69 | password = input("Enter the password: ") |
| 70 | |
| 71 | decrypted = decrypt(encrypted, password) |
| 72 | print("\n\nDecrypted:") |
| 73 | print("-----------------\n") |
| 74 | print(decrypted) |
| 75 | except ValueError as e: |
| 76 | print(f"Error: {e}") |
| 77 | |
| 78 | |
| 79 | if __name__ == "__main__": |