Exemple #1
0
 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)
Exemple #2
0
 def test_regression_vectors(self):
     for vector in self.regression_vectors:
         result = pbkdf2(**vector["args"])
         self.assertEqual(binascii.hexlify(result).decode("ascii"), vector["result"])