def encrypt(password='<STR_LIT:password>', salt=None):
if not salt:<EOL><INDENT>salt = str(datetime.utcnow())<EOL><DEDENT>try:<EOL><INDENT>dk = hashlib.pbkdf2_hmac('<STR_LIT>', password.encode(), salt.encode(), <NUM_LIT>)<EOL>hexdigest = binascii.hexlify(dk).decode('<STR_LIT:utf-8>')<EOL><DEDENT>except AttributeError:<EOL><INDENT>dk = hashlib.sha1()<EOL>dk.update(password.encode() + salt.encode())<EOL>hexdigest = dk.hexdigest()<EOL><DEDENT>return hexdigest<EOL>
Return SHA1 hexdigest of a password (optionally salted with a string).