Я поместил элемент в AWS DynamoDB, который находится в двоичной форме. Я имею в виду, что мои данные в зашифрованном виде, и когда я пытаюсь получить доступ к этим данным для печати или назначения, я не могу сменить Python
import boto3
import base64
dynamodb = boto3.resource('dynamodb', region_name='us-west-2')
table = dynamodb.Table('xyz')
response = table.get_item(
Key={
'id': "2",
}
)
item = response['Item']
dec_otp=item['otp']
print(dec_otp) #not able to print
a=dec_otp #not able to assign
print(type(dec_otp))
print(item)
Выход: -
Traceback (most recent call last):
File "aws_kms3.py", line 23, in <module>
'name': 'otp'
File "/home/vinit/Desktop/kms/venv/lib/python3.6/site-packages/botocore/client.py", line 314, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/vinit/Desktop/kms/venv/lib/python3.6/site-packages/botocore/client.py", line 586, in _make_api_call
api_params, operation_model, context=request_context)
File "/home/vinit/Desktop/kms/venv/lib/python3.6/site-packages/botocore/client.py", line 621, in _convert_to_request_dict
api_params, operation_model)
File "/home/vinit/Desktop/kms/venv/lib/python3.6/site-packages/botocore/validate.py", line 291, in serialize_to_request
raise ParamValidationError(report=report.generate_report())
File "/home/vinit/Desktop/kms/venv/lib/python3.6/site-packages/botocore/validate.py", line 95, in generate_report
error_messages.append(self._format_error(error))
File "/home/vinit/Desktop/kms/venv/lib/python3.6/site-packages/botocore/validate.py", line 112, in _format_error
', '.join(additional['valid_types']))
TypeError: __str__ returned non-string (type bytes)
output2: -
Traceback (most recent call last):
File "aws_kms3.py", line 25, in <module>
CiphertextBlob=bytes(base64.b64decode(dec_otp))
File "/home/vinit/Desktop/kms/venv/lib/python3.6/base64.py", line 80, in b64decode
s = _bytes_from_decode_data(s)
File "/home/vinit/Desktop/kms/venv/lib/python3.6/base64.py", line 46, in _bytes_from_decode_data
"string, not %r" % s.__class__.__name__) from None
TypeError: argument should be a bytes-like object or ASCII string, not 'Binary'
output3: -
Binary object is not itterable