Python passlib.hash.pbkdf2_sha256.encrypt() Examples
The following are 9
code examples of passlib.hash.pbkdf2_sha256.encrypt().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
passlib.hash.pbkdf2_sha256
, or try the search function
.
Example #1
Source File: db.py From vulpy with MIT License | 6 votes |
def db_init(): users = [ ('admin', pbkdf2_sha256.encrypt('123456')), ('john', pbkdf2_sha256.encrypt('Password')), ('tim', pbkdf2_sha256.encrypt('Vaider2')) ] conn = sqlite3.connect('users.sqlite') c = conn.cursor() c.execute("DROP TABLE users") c.execute("CREATE TABLE users (user text, password text, failures int)") for u,p in users: c.execute("INSERT INTO users (user, password, failures) VALUES ('%s', '%s', '%d')" %(u, p, 0)) conn.commit() conn.close()
Example #2
Source File: DatabaseLayer.py From watchdog with Apache License 2.0 | 5 votes |
def addUser(user, pwd, admin=False, localOnly=False): hashed = pbkdf2_sha256.encrypt(pwd, rounds=hash_rounds, salt_size=salt_size) entry = {'username':user, 'password':hashed} if admin: entry['master']= True if localOnly: entry['local_only']= True colUSERS.insert(entry)
Example #3
Source File: DatabaseLayer.py From watchdog with Apache License 2.0 | 5 votes |
def changePassword(user, pwd): hashed = pbkdf2_sha256.encrypt(pwd, rounds=hash_rounds, salt_size=salt_size) colUSERS.update({'username': user}, {'$set': {'password': hashed}})
Example #4
Source File: users.py From hackit with Apache License 2.0 | 5 votes |
def __init__(self, username, password, pubname, email, seat=None): self.username = username self.password = pbkdf2_sha256.encrypt(password) self.pubname = pubname self.email = email self.seat = seat
Example #5
Source File: users.py From hackit with Apache License 2.0 | 5 votes |
def changepassword(self, pwd): self.password = pbkdf2_sha256.encrypt(pwd)
Example #6
Source File: models.py From papers with MIT License | 5 votes |
def hash_password(password): return pbkdf2_sha256.encrypt(password, rounds=200000, salt_size=16)
Example #7
Source File: save_password.py From PenguinDome with Apache License 2.0 | 5 votes |
def main(): args = parse_args() if not args.password: args.password = getpass.getpass('Password:') password2 = getpass.getpass('Confirm password:') if args.password != password2: sys.exit('Passwords do not match') if args.setting: setting_path = 'server_auth:{}:passwords:{}'.format( args.setting, args.USERNAME) else: setting_path = 'users:{}'.format(args.USERNAME) hashed = pbkdf2_sha256.encrypt(args.password, rounds=200000, salt_size=16) set_setting(setting_path, hashed) save_settings()
Example #8
Source File: authentication_retrieval_point.py From calvin-base with Apache License 2.0 | 5 votes |
def hash_passwords(self, data): """Change the content of the users database""" import time #TODO: remove printing passwords into log _log.debug("hash_passwords\n\tdata={}".format(data)) updates_made = False start = time.time() for username in data: user_data = data[username] try: is_pbkdf2 = pbkdf2_sha256.identify(user_data['password']) except Exception as err: _log.error("Failed to identify if password is PBKDF2 or not:" "\n\tusername={}" "\n\tuser_data={}" "\n\terr={}".format(username, user_data, err)) raise #If the password is in clear, let's hash it with a salt and store that instead if ('password' in user_data) and not (is_pbkdf2): try: hash = pbkdf2_sha256.encrypt(user_data['password'], rounds=200000, salt_size=16) except Exception as err: _log.error("Failed to calculate PBKDF2 of password, err={}".format(err)) raise user_data['password']=hash updates_made = True _log.debug("hashed_passwords" "\n\tdata={}" "\n\ttime it took to hash passwords={}".format(data, time.time()-start)) return updates_made
Example #9
Source File: models.py From flask-api-boilerplate with MIT License | 5 votes |
def set_password(self, password): self.password = pbkdf2_sha256.encrypt(password) return self.password