!! pw key #!/usr/bin/env python3 # -*- coding: utf-8 -*- import getpass import crypt import hashlib import random pw = getpass.getpass() ## salt = hashlib.sha1(str(random.random())).hexdigest() # salt = hashlib.sha256(b'test').hexdigest() salt = hashlib.sha1(bytes(random.randint(32,90))).hexdigest() print ( crypt.crypt( pw , "$1$" + salt + "$") )