The code incorrectly assumes that base64 is byte encoded so something like:
elif content_encoding.lower() == 'base64': if not isinstance(unencrypted, six.binary_type): b64payload = unencrypted.encode('utf-8') else: b64payload = unencrypted
does the trick in terms of ensuring binary encoding of the data in this code path.
The code incorrectly assumes that base64 is byte encoded so something like:
elif content_ encoding. lower() == 'base64': unencrypted, six.binary_type):
b64payload = unencrypted. encode( 'utf-8' )
b64payload = unencrypted
if not isinstance(
else:
does the trick in terms of ensuring binary encoding of the data in this code path.