2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 17:43:14 +00:00

Auto-encode unicode if needed

If unicode comes in to be crypted and fails, be explicit about utf-8 encoding.
This commit is contained in:
Jarrod Johnson 2017-06-09 18:57:30 -04:00
parent aeb3bd2444
commit 0745ab0fdf

View File

@ -261,7 +261,10 @@ def crypt_value(value,
neededpad = 16 - (len(value) % 16)
pad = chr(neededpad) * neededpad
value += pad
cryptval = crypter.encrypt(value)
try:
cryptval = crypter.encrypt(value)
except TypeError:
cryptval = crypter.encrypt(value.encode('utf-8'))
hmac = HMAC.new(integritykey, cryptval, SHA256).digest()
return iv, cryptval, hmac