0

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.

activedecay
  • 10,129
  • 5
  • 47
  • 71
  • 1
    For 3.6, secrets could be helpful: https://docs.python.org/3/library/secrets.html – Bailey Parker Mar 23 '18 at 04:28
  • `cryptography` has lots of key generation algorithms: https://cryptography.io/en/latest/hazmat/primitives/key-derivation-functions/ . `openssl`'s default algorithm, `crypt` is usually considered obsoleted. – halfelf Mar 23 '18 at 04:52
  • anyone know which algorithm is used? trying to troubleshoot if the "unix standard algorithm crypt" is being used internally in `openssl passwd`. then if i knew which algo was used, i could more easily validate that the input + salt returned the right value. – activedecay Mar 23 '18 at 04:56

1 Answers1

2

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'
halfelf
  • 9,737
  • 13
  • 54
  • 63