Esempio n. 1
0
 def generate(self, cli_object):
     if cli_object.salt is not False:
         if cli_object.rounds is not False:
             generatedhash = sha1_crypt.encrypt(cli_object.plaintext, rounds=int(cli_object.rounds), salt=cli_object.salt)
             return generatedhash
         else:
             generatedhash = sha1_crypt.encrypt(cli_object.plaintext, salt=cli_object.salt)
             return generatedhash
     else:
         if cli_object.rounds is not False:
             generatedhash = sha1_crypt.encrypt(cli_object.plaintext, rounds=int(cli_object.rounds))
             return generatedhash
         else:
             generatedhash = sha1_crypt.encrypt(cli_object.plaintext)
             return generatedhash
     return
Esempio n. 2
0
# coding=utf-8

# pip install passlib
# http://pythonhosted.org/passlib/genindex.html
from passlib.hash import md5_crypt, sha256_crypt, sha512_crypt, sha1_crypt
password = '******'
sha1 = sha1_crypt.encrypt(password)
md5 = md5_crypt.encrypt(password) # /etc/shadow
sha256 = sha256_crypt.encrypt(password)
sha512 = sha512_crypt.encrypt(password)
print(md5,sha256,sha512,sha1)
md5_crypt.verify(password, md5) # 验证password和hash值
Esempio n. 3
0
 def hash(self, email_address):
   # todo: 1. support for other hash algorithms based on hash_params.name
   return sha1_crypt.encrypt(email_address, rounds=self.hash_params.rounds, salt=self.hash_params.salt)
Esempio n. 4
0
 def set_password(password):
     """Set password."""
     password = sha1_crypt.encrypt(password)
     return password
Esempio n. 5
0
 def hash_password(self, password):
     return sha1_crypt.encrypt(password, salt=self.salt)
Esempio n. 6
0
 def hash(self, email_address):
     # todo: 1. support for other hash algorithms based on hash_params.name
     return sha1_crypt.encrypt(email_address,
                               rounds=self.hash_params.rounds,
                               salt=self.hash_params.salt)