コード例 #1
0
 def to_string(self):
     ident = self.ident
     if ident == IDENT_SCRYPT:
         return "$scrypt$ln=%d,r=%d,p=%d$%s$%s" % (
             self.rounds,
             self.block_size,
             self.parallelism,
             bascii_to_str(b64s_encode(self.salt)),
             bascii_to_str(b64s_encode(self.checksum)),
         )
     else:
         assert ident == IDENT_7
         salt = self.salt
         try:
             salt.decode("ascii")
         except UnicodeDecodeError:
             raise suppress_cause(
                 NotImplementedError(
                     "scrypt $7$ hashes dont support non-ascii salts"))
         return bascii_to_str(b"".join([
             b"$7$",
             h64.encode_int6(self.rounds),
             h64.encode_int30(self.block_size),
             h64.encode_int30(self.parallelism), self.salt, b"$",
             h64.encode_bytes(self.checksum)
         ]))
コード例 #2
0
ファイル: phpass.py プロジェクト: cutso/passlib
 def to_string(self):
     hash = u("%s%s%s%s") % (
         self.ident,
         h64.encode_int6(self.rounds).decode("ascii"),
         self.salt,
         self.checksum or u(""),
     )
     return uascii_to_str(hash)
コード例 #3
0
ファイル: SQLIdResolver.py プロジェクト: windkit/privacyidea
 def to_string(self):
     hash = u"%s%s%s%s" % (self.ident, h64.encode_int6(
         self.rounds).decode("ascii"), self.salt, self.checksum or u'')
     return uascii_to_str(hash)
コード例 #4
0
ファイル: test_utils.py プロジェクト: jiningeast/netcontrol
 def test_encode_int6(self):
     self.assertEqual(h64.encode_int6(0), b('.'))
     self.assertEqual(h64.encode_int6(63), b('z'))
     self.assertRaises(ValueError, h64.encode_int6, -1)
     self.assertRaises(ValueError, h64.encode_int6, 64)
コード例 #5
0
 def test_encode_int6(self):
     self.assertEqual(h64.encode_int6(0),b('.'))
     self.assertEqual(h64.encode_int6(63),b('z'))
     self.assertRaises(ValueError, h64.encode_int6, -1)
     self.assertRaises(ValueError, h64.encode_int6, 64)
コード例 #6
0
ファイル: phpass.py プロジェクト: GabrielDiniz/FluxNetControl
 def to_string(self):
     hash = u"%s%s%s%s" % (self.ident,
                           h64.encode_int6(self.rounds).decode("ascii"),
                           self.salt,
                           self.checksum or u'')
     return to_hash_str(hash)