Search code examples
pythonpyopenssl

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

Here is an example of a working commandline:

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

Is there a python module that handles password generation with openssl? The documentation doesn't appear to cover generating passwords.


Solution

  • If you need the same behavior like openssl passwd, which using unix standard crypt(3), python has a crypt module:

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