Example #1
0
 def test_verifyable_hash(self):
     password = '******'
     hash = pwhash.Hash(password=password)
     hashed = str(hash)
     hash2 = pwhash.Hash()
     hash2.set_hash(hashed)
     assert hash2.verify(password)
Example #2
0
 def test_bad_hash(self):
     hash = pwhash.Hash()
     self.assertRaises(pwhash.InvalidHashStringError, hash.set_hash,
                       'badc0ffee')
Example #3
0
 def test_verify_md5_hash(self):
     hash = pwhash.Hash()
     hash.set_hash('{md5}e7MaFMQE$wbzoUnM9Jju9ob9bY29+hA==')
     self.assert_(hash.verify('foobar'))
     self.assertFalse(hash.verify('blueparrot'))
Example #4
0
 def test_verify_sha1_hash(self):
     hash = pwhash.Hash()
     hash.set_hash('{sha1}e7MaFMQE$cCqMIINS5t85J0MIgNwMprXBfLA=')
     self.assert_(hash.verify('foobar'))
     self.assertFalse(hash.verify('blueparrot'))
Example #5
0
 def test_pbkdf25_hash(self):
     hash = pwhash.Hash('pbkdf2', 'e7MaFMQE', 'foobar')
     self.assertEquals(
         '{pbkdf2}e7MaFMQE$7j7bgQb8xED7mEY+8g1QM2zs/ispKZVeNEv/nMCYPX0=',
         str(hash))
Example #6
0
 def test_md5_hash(self):
     hash = pwhash.Hash('md5', 'e7MaFMQE', 'foobar')
     self.assertEquals('{md5}e7MaFMQE$wbzoUnM9Jju9ob9bY29+hA==', str(hash))
Example #7
0
 def test_sha1_hash(self):
     hash = pwhash.Hash('sha1', 'e7MaFMQE', 'foobar')
     self.assertEquals('{sha1}e7MaFMQE$cCqMIINS5t85J0MIgNwMprXBfLA=',
                       str(hash))
Example #8
0
 def test_bad_hash(self):
     hash = pwhash.Hash()
     with pytest.raises(pwhash.InvalidHashStringError):
         hash.set_hash('badc0ffee')
Example #9
0
 def test_unknown_hash(self):
     with pytest.raises(pwhash.UnknownHashMethodError):
         pwhash.Hash('montyhash', 'e7MaFMQE', 'foobar')
Example #10
0
 def test_md5_hash(self):
     hash = pwhash.Hash('md5', 'e7MaFMQE', 'foobar')
     assert '{md5}e7MaFMQE$wbzoUnM9Jju9ob9bY29+hA==' == str(hash)
Example #11
0
 def test_sha1_hash(self):
     hash = pwhash.Hash('sha1', 'e7MaFMQE', 'foobar')
     assert '{sha1}e7MaFMQE$cCqMIINS5t85J0MIgNwMprXBfLA=' == str(hash)