@@ -114,7 +114,7 @@ def ssha(password, salt):
114114 '''
115115 shaval = sha1 (password ) # nosec
116116 shaval .update (salt )
117- ssha_digest = b64encode (shaval .digest () + salt ).strip ()
117+ ssha_digest = b2s ( b64encode (shaval .digest () + salt ).strip () )
118118 return ssha_digest
119119
120120
@@ -359,13 +359,17 @@ def __str__(self):
359359def test ():
360360 # SHA
361361 p = Password ('sekrit' )
362+ assert Password (encrypted = str (p )) == 'sekrit'
363+ assert 'sekrit' == Password (encrypted = str (p ))
362364 assert p == 'sekrit'
363365 assert p != 'not sekrit'
364366 assert 'sekrit' == p
365367 assert 'not sekrit' != p
366368
367369 # MD5
368370 p = Password ('sekrit' , 'MD5' )
371+ assert Password (encrypted = str (p )) == 'sekrit'
372+ assert 'sekrit' == Password (encrypted = str (p ))
369373 assert p == 'sekrit'
370374 assert p != 'not sekrit'
371375 assert 'sekrit' == p
@@ -374,13 +378,17 @@ def test():
374378 # crypt
375379 if crypt : # not available on Windows
376380 p = Password ('sekrit' , 'crypt' )
381+ assert Password (encrypted = str (p )) == 'sekrit'
382+ assert 'sekrit' == Password (encrypted = str (p ))
377383 assert p == 'sekrit'
378384 assert p != 'not sekrit'
379385 assert 'sekrit' == p
380386 assert 'not sekrit' != p
381387
382388 # SSHA
383389 p = Password ('sekrit' , 'SSHA' )
390+ assert Password (encrypted = str (p )) == 'sekrit'
391+ assert 'sekrit' == Password (encrypted = str (p ))
384392 assert p == 'sekrit'
385393 assert p != 'not sekrit'
386394 assert 'sekrit' == p
@@ -397,6 +405,8 @@ def test():
397405
398406 # PBKDF2 - high level integration
399407 p = Password ('sekrit' , 'PBKDF2' )
408+ assert Password (encrypted = str (p )) == 'sekrit'
409+ assert 'sekrit' == Password (encrypted = str (p ))
400410 assert p == 'sekrit'
401411 assert p != 'not sekrit'
402412 assert 'sekrit' == p
0 commit comments