Skip to content

Commit

Permalink
Merge pull request ipython#4526 from takluyver/passwd_check_unicode
Browse files Browse the repository at this point in the history
Allow unicode arguments to passwd_check on Python 2

Closes ipython#4524
  • Loading branch information
minrk committed Nov 12, 2013
2 parents b45e31b + 9bea1d3 commit ec6e7e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion IPython/lib/security.py
Expand Up @@ -113,6 +113,6 @@ def passwd_check(hashed_passphrase, passphrase):
if len(pw_digest) == 0:
return False

h.update(cast_bytes(passphrase, 'utf-8') + str_to_bytes(salt, 'ascii'))
h.update(cast_bytes(passphrase, 'utf-8') + cast_bytes(salt, 'ascii'))

return h.hexdigest() == pw_digest
5 changes: 5 additions & 0 deletions IPython/lib/tests/test_security.py
@@ -1,3 +1,4 @@
# coding: utf-8
from IPython.lib import passwd
from IPython.lib.security import passwd_check, salt_len
import nose.tools as nt
Expand All @@ -19,3 +20,7 @@ def test_bad():
nt.assert_equal(passwd_check(p, 'a:b:c:d'), False)
nt.assert_equal(passwd_check(p, 'a:b'), False)

def test_passwd_check_unicode():
# GH issue #4524
phash = u'sha1:23862bc21dd3:7a415a95ae4580582e314072143d9c382c491e4f'
assert passwd_check(phash, u"łe¶ŧ←↓→")

0 comments on commit ec6e7e1

Please sign in to comment.