KMS encryption under Python 3 (#826)
This upgrades the KMS encrypt and decrypt endpoints to work under both Python 2 and 3
This commit is contained in:
parent
fd7b8e7c88
commit
53fbd7dca0
2 changed files with 22 additions and 22 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||
import base64
|
||||
import json
|
||||
import re
|
||||
import six
|
||||
|
||||
from boto.exception import JSONResponseError
|
||||
from boto.kms.exceptions import AlreadyExistsException, NotFoundException
|
||||
|
|
@ -220,11 +221,14 @@ class KmsResponse(BaseResponse):
|
|||
decode it in decrypt().
|
||||
"""
|
||||
value = self.parameters.get("Plaintext")
|
||||
return json.dumps({"CiphertextBlob": base64.b64encode(value).encode("utf-8")})
|
||||
if isinstance(value, six.text_type):
|
||||
value = value.encode('utf-8')
|
||||
return json.dumps({"CiphertextBlob": base64.b64encode(value).decode("utf-8")})
|
||||
|
||||
def decrypt(self):
|
||||
value = self.parameters.get("CiphertextBlob")
|
||||
return json.dumps({"Plaintext": base64.b64decode(value).encode("utf-8")})
|
||||
print("value 3", value)
|
||||
return json.dumps({"Plaintext": base64.b64decode(value).decode("utf-8")})
|
||||
|
||||
|
||||
def _assert_valid_key_id(key_id):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue