File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,12 @@ def _is_unicode(val):
55
55
return (type (val ) == _TYPE_UNICODE )
56
56
57
57
58
+ def encode_unicode_string (unicode_string ):
59
+ """Convert a unicode string value to bytes."""
60
+
61
+ return codecs .encode (unicode_string , 'utf8' )
62
+
63
+
58
64
def ensure_native_string (string_or_bytes ):
59
65
"""Given a supplied input which can be either a string or bytes
60
66
return a representation providing string operations while ensuring that
Original file line number Diff line number Diff line change 44
44
import time
45
45
46
46
from mig .shared .base import force_utf8 , mask_creds , string_snippet
47
+ from mig .shared .compat import encode_unicode_string
47
48
from mig .shared .defaults import keyword_auto , RESET_TOKEN_TTL
48
49
49
50
@@ -118,7 +119,7 @@ def best_crypt_salt(configuration):
118
119
def make_hash (password , _urandom = urandom ):
119
120
"""Generate a random salt and return a new hash for the password."""
120
121
salt = b64encode (_urandom (SALT_LENGTH ))
121
- password_bytes = codecs . encode (password , 'utf8' )
122
+ password_bytes = encode_unicode_string (password )
122
123
password_hashed = hashlib .pbkdf2_hmac (HASH_FUNCTION ,
123
124
password_bytes , salt ,
124
125
COST_FACTOR , KEY_LENGTH )
You can’t perform that action at this time.
0 commit comments