コード例 #1
0
ファイル: test_crypto.py プロジェクト: huahu/tornado-webtools
 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'
     )
コード例 #2
0
ファイル: hashers.py プロジェクト: daqing15/tornado-webtools
 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)
コード例 #3
0
ファイル: hashers.py プロジェクト: huahu/tornado-webtools
 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)
コード例 #4
0
 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')