Where is "mkpasswd" for OSX?

Solution 1:

There's a Mac implementation of mkpasswd on GitHub - https://github.com/PrototypeAlex/mkpasswd

Alternatively, Keychain Access has a built-in GUI password generator
File menu > New Password Item... > [click the key icon]

drop-menu artificially offset for visibility

enter image description here

I also found this Apple Discussion on how to achieve it natively, though it's unfortunately above my skill-level, so I'll let you see if you think it might be suitable.

Solution 2:

I made a tool for creating mkpasswd -m sha-512 (Linux/Ubuntu) style hashes on OS X (or any platform).

First, we need to acquire a single requirement...

pip3 install passlib

Now we create mkpasswd_sha-512.py (or whatever you want to call it)...

#!/usr/bin/env python3

# based on https://stackoverflow.com/a/17992126/117471

import sys
from getpass import getpass
from passlib.hash import sha512_crypt

passwd = input() if not sys.stdin.isatty() else getpass()
print(sha512_crypt.encrypt(passwd))

It only handles a single use case of mkpasswd but if it fits, enjoy.

Note: There is a slightly more complicated version at https://gist.github.com/RichardBronosky/58f1b34d2bcf4c4e5f1cd18a88fdc37d which simplifies tuning the CPU Cost, but passlib manages that periodically for you so it's fine to keep it simple like this.