python 版本的 openssl 密码

python version of openssl passwd

The openssl passwd command computes the hash of a password typed at run-time or the hash of each password in a list. The password list is taken from the named file for option -in file, from stdin for option -stdin, and from the command line otherwise. The UNIX standard algorithm crypt and the MD5-based BSD password algorithm 1 and its Apache variant apr1 are available.

https://www.mkssoftware.com/docs/man1/openssl_passwd.1.asp

这里是一个工作命令行的例子:

# openssl passwd -salt lol "input"
lokvI0eY9X.FM

是否有 python 模块使用 openssl 处理密码生成? The documentation doesn't appear to cover generating passwords.

如果您需要与 openssl passwd 相同的行为,它使用 unix 标准 crypt(3),python 有一个 crypt 模块:

import crypt
crypt.crypt('input', salt='lol') # => 'lokvI0eY9X.FM'