def test_pbkdf2(self): from webtools.utils.crypto import pbkdf2 res = pbkdf2("test", "some-salt", 10) self.assertEqual( res, b'X\xf0\xdd\xea3\x0b\x9b.\xe8\xad\x1a\xb8}\x90\xb5i\xd3a"\x9as\x1f\xa3\x8d\x17\xff\xff\x8f\r\xb2\xaf\x7f' )
def encode(self, password, salt, iterations=None): assert password assert salt and '$' not in salt if not iterations: iterations = self.iterations hash = pbkdf2(password, salt, iterations, digest=self.digest) hash = base64.b64encode(hash).decode('ascii').strip() return "%s$%d$%s$%s" % (self.algorithm, iterations, salt, hash)
def test_pbkdf2(self): from webtools.utils.crypto import pbkdf2 res = pbkdf2("test", "some-salt", 10) self.assertEqual(res, b'X\xf0\xdd\xea3\x0b\x9b.\xe8\xad\x1a\xb8}\x90\xb5i\xd3a"\x9as\x1f\xa3\x8d\x17\xff\xff\x8f\r\xb2\xaf\x7f')