From 35cababff4f2945a9a4c041336e706e748365c1b Mon Sep 17 00:00:00 2001 From: Doug Schwartz Date: Thu, 17 Aug 2017 11:55:20 -0700 Subject: [PATCH] Updated KMS Python examples to remove unused imports --- python/example_code/kms/kms-python-example-decrypt-blob.py | 2 +- python/example_code/kms/kms-python-example-encrypt-data.py | 7 +++---- .../example_code/kms/kms-python-example-re-encrypt-data.py | 7 +------ 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/python/example_code/kms/kms-python-example-decrypt-blob.py b/python/example_code/kms/kms-python-example-decrypt-blob.py index 81305105a05..06b81bdec15 100644 --- a/python/example_code/kms/kms-python-example-decrypt-blob.py +++ b/python/example_code/kms/kms-python-example-decrypt-blob.py @@ -14,7 +14,7 @@ # Decrypt blob -blob = '\x01\x02\x02\x00xl\xf0\xbc5_\x1bJ\x14\xb6\xe0\x1e\xcfg.\xb3\x805\r\x02\xd0a\xd2s\xfd\xe8\xe8\x03"T\x17\xb2@\x01\xf2\xb2\xd5iMd%\x84\xca\xdf\xb0\xe1\xa5\x9c\x15O\x00\x00\x00h0f\x06\t*\x86H\x86\xf7\r\x01\x07\x06\xa0Y0W\x02\x01\x000R\x06\t*\x86H\x86\xf7\r\x01\x07\x010\x1e\x06\t`\x86H\x01e\x03\x04\x01.0\x11\x04\x0cU\xfd|\xc8\xd7\xd0\xf9*\x17\x8bF\xbf\x02\x01\x10\x80%"\x92\xda\xbf\xa0\xd0Z\xc9\xa56\xcf\xb8\xed\xc6\xf1.\xae\xd4\x84\xa6[s\x82\xfb\xe8\xe2\xd8\x05u\xf4h\xed\x9eF\xad\xb7\xfc' +blob = '\x01\x02\x02...' client = boto3.client('kms') diff --git a/python/example_code/kms/kms-python-example-encrypt-data.py b/python/example_code/kms/kms-python-example-encrypt-data.py index c8356b0b1cb..74ff0d18938 100644 --- a/python/example_code/kms/kms-python-example-encrypt-data.py +++ b/python/example_code/kms/kms-python-example-encrypt-data.py @@ -12,13 +12,12 @@ import boto3 import base64 -import binascii -# Decrypt data +# Encrypt data # -# Replace the fictitious blob with a valid blob +# Replace the fictitious key ARN with a valid key ID -keyId = 'arn:aws:kms:us-west-2:188580781645:key/cd6b2911-8ed2-4783-87d9-499af9a13af4' +keyId = 'arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab' text = '1234567890' text_64 = base64.b64encode(text) diff --git a/python/example_code/kms/kms-python-example-re-encrypt-data.py b/python/example_code/kms/kms-python-example-re-encrypt-data.py index 40cdaba8871..48a15bbe7f5 100644 --- a/python/example_code/kms/kms-python-example-re-encrypt-data.py +++ b/python/example_code/kms/kms-python-example-re-encrypt-data.py @@ -11,20 +11,15 @@ # language governing permissions and limitations under the License. import boto3 -import base64 -import binascii # Re-ecrypt data -blob = '\x01\x02\x02\x00xl\xf0\xbc5_\x1bJ\x14\xb6\xe0\x1e\xcfg.\xb3\x805\r\x02\xd0a\xd2s\xfd\xe8\xe8\x03"T\x17\xb2@\x01\xf2\xb2\xd5iMd%\x84\xca\xdf\xb0\xe1\xa5\x9c\x15O\x00\x00\x00h0f\x06\t*\x86H\x86\xf7\r\x01\x07\x06\xa0Y0W\x02\x01\x000R\x06\t*\x86H\x86\xf7\r\x01\x07\x010\x1e\x06\t`\x86H\x01e\x03\x04\x01.0\x11\x04\x0cU\xfd|\xc8\xd7\xd0\xf9*\x17\x8bF\xbf\x02\x01\x10\x80%"\x92\xda\xbf\xa0\xd0Z\xc9\xa56\xcf\xb8\xed\xc6\xf1.\xae\xd4\x84\xa6[s\x82\xfb\xe8\xe2\xd8\x05u\xf4h\xed\x9eF\xad\xb7\xfc' +blob = '\x01\x02\x02\...' # Replace the fictitious key ARN with a valid key ID destinationKeyId = 'arn:aws:kms:us-west-2:111122223333:key/0987dcba-09fe-87dc-65ba-ab0987654321' -# DELETE BEFORE PUBLISHING -destinationKeyId = 'arn:aws:kms:us-west-2:188580781645:key/cd6b2911-8ed2-4783-87d9-499af9a13af4' - client = boto3.client('kms') response = client.re_encrypt(