From 3ef54c3285c3727edf60203d754f71b0e90b75f2 2013-11-12 19:44:41 From: Min RK Date: 2013-11-12 19:44:41 Subject: [PATCH] Merge pull request #4526 from takluyver/passwd_check_unicode Allow unicode arguments to passwd_check on Python 2 Closes #4524 --- diff --git a/IPython/lib/security.py b/IPython/lib/security.py index f90ca98..d5c61cb 100644 --- a/IPython/lib/security.py +++ b/IPython/lib/security.py @@ -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 diff --git a/IPython/lib/tests/test_security.py b/IPython/lib/tests/test_security.py index 09e4fa8..7d89ba1 100644 --- a/IPython/lib/tests/test_security.py +++ b/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 @@ -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¶ŧ←↓→") \ No newline at end of file