1 from ctypescrypto.pbkdf2 import pbkdf2
4 class TestPBKDF2(unittest.TestCase):
5 answersha1='\xc13\xb3\xc8\x80\xc2\t\x01\xdaR]\x08\x03\xaf>\x85\xed\x9bU\xf0\x89\n\x81Ctu\xee\xe3\xfe\xd9\xfd\x85\xe2"\x8c\xfbQ\xfeb4\x8f(ZF\xfd\xc3w\x13'
6 answersha256='oY\xaf\xf7\xfeB7@\xa80%\t\'\xd5r0\xbe\xb4\xf7\xe6TQ\xd2|Tx\xc0e\xff[0a\xe56\xec\xff\xda\xcd\xed~\xbde\xad"\xe8\t\x01o'
7 answersha1_1000='\xe9\xfe\xbf\xf5K\xfc\xe6h\xfd\xe3\x01\xac\xc8Uc\xcc\x9d\xc7\x1e\xf6\xf8\xd7\xaa\xef\x06se\xbe\x0e^e"\xefa\xba\xe1\xb0\x0b\xc1;\xcd\x05G<\xcc\rE\xfb'
8 def test_defaults(self):
9 d=pbkdf2("password","saltsalt",48)
10 self.assertEqual(d,self.answersha1)
12 d=pbkdf2("password","saltsalt",48,digesttype="sha1",iterations=2000)
13 self.assertEqual(d,self.answersha1)
14 def test_1000iter(self):
15 d=pbkdf2("password","saltsalt",48,digesttype="sha1",iterations=1000)
16 self.assertEqual(d,self.answersha1_1000)
17 def test_sha256(self):
18 d=pbkdf2("password","\01\02\03\04\0abc",48,digesttype="sha256")
19 self.assertEqual(d,self.answersha256)
21 if __name__ == "__main__":