Skip to content

Instantly share code, notes, and snippets.

@lxhunter
Created February 28, 2017 10:08
Show Gist options
  • Save lxhunter/ac41f2cf52884ed72f5fdef779e45748 to your computer and use it in GitHub Desktop.
Save lxhunter/ac41f2cf52884ed72f5fdef779e45748 to your computer and use it in GitHub Desktop.
use python passlib to generate sha512-crypt on osx with optional rounds
#!/usr/bin/env python
# pip install passlib
import getpass
import random
import string
import argparse
from passlib.hash import sha512_crypt
parser = argparse.ArgumentParser()
parser.add_argument('--rounds', type=int, default=5000, help='specify the rounds')
args = parser.parse_args()
print sha512_crypt.using(salt=''.join([random.choice(string.ascii_letters + string.digits) for _ in range(16)]),
rounds=args.rounds).hash(getpass.getpass())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment