Use smart_str instead of .encode on passwords

We originally tried to prune these .encode() calls out of the tree in
favor of smart_str but we must have missed this one.   This allows
migration 0066 to work if utf-8 characters are used in the password
This commit is contained in:
Matthew Jones 2015-08-13 16:54:27 -04:00
parent d4dccff20c
commit ee8a76f32b

View File

@ -147,7 +147,7 @@ def encrypt_field(instance, field_name, ask=False):
value = getattr(instance, field_name)
if not value or value.startswith('$encrypted$') or (ask and value == 'ASK'):
return value
value = value.encode('utf-8')
value = smart_str(value)
key = get_encryption_key(instance, field_name)
cipher = AES.new(key, AES.MODE_ECB)
while len(value) % cipher.block_size != 0: