Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions python/example_code/kms/key_encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def from_client(cls) -> "KeyEncrypt":
# snippet-end:[python.example_code.kms.KeyEncrypt.decl]

# snippet-start:[python.example_code.kms.Encrypt]
def encrypt(self, key_id: str, text: str) -> str:
def encrypt(self, key_id: str, text: str) -> bytes:
"""
Encrypts text by using the specified key.

Expand Down Expand Up @@ -64,7 +64,7 @@ def encrypt(self, key_id: str, text: str) -> str:
# snippet-end:[python.example_code.kms.Encrypt]

# snippet-start:[python.example_code.kms.Decrypt]
def decrypt(self, key_id: str, cipher_text: str) -> bytes:
def decrypt(self, key_id: str, cipher_text: bytes) -> str:
"""
Decrypts text previously encrypted with a key.

Expand All @@ -75,7 +75,7 @@ def decrypt(self, key_id: str, cipher_text: str) -> bytes:
try:
return self.kms_client.decrypt(KeyId=key_id, CiphertextBlob=cipher_text)[
"Plaintext"
]
].decode()
except ClientError as err:
logger.error(
"Couldn't decrypt your ciphertext. Here's why: %s",
Expand Down Expand Up @@ -198,7 +198,7 @@ def key_encryption(kms_client):
answer = input("Ready to decrypt your ciphertext (y/n)? ")
if answer.lower() == "y":
decrypted_text = key_encrypt.decrypt(key_id, cipher_text)
print(f"Your plaintext is {decrypted_text.decode()}")
print(f"Your plaintext is {decrypted_text}")
print("-" * 88)
key_encrypt.re_encrypt(key_id, cipher_text)
else:
Expand Down
Loading