def do_passhash(args):
"""
Uses bcrypt to hash a password.
:param args: Parsed ArgumentParser args
:type args: argparse.Namespace
:returns: The hashed password
:rtype: str
"""
import bcrypt
if args.password is not None:
pw = args.password
elif args.file is not None:
pw = args.file.read()
else:
import getpass
pw = getpass.getpass()
salt = bcrypt.gensalt(log_rounds=args.rounds)
return bcrypt.hashpw(pw, salt)
评论列表
文章目录