From c3e7d642fbf2e0d0ccbf4a3fd7bd71322cc78d28 Mon Sep 17 00:00:00 2001 From: Ken Fong Date: Mon, 21 Jan 2019 21:43:32 +0800 Subject: [PATCH] added genpw.py --- README.md | 2 +- genpw.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 genpw.py diff --git a/README.md b/README.md index d1b29e7..977d5c5 100644 --- a/README.md +++ b/README.md @@ -31,5 +31,5 @@ Create a playbook like this ## How to generate pwhash ```mkpasswd -m sha-512``` -or use the following python script which generates random password and a hash at the same time +Or genpw.py which generates random password and a hash at the same time. diff --git a/genpw.py b/genpw.py new file mode 100644 index 0000000..573d7a2 --- /dev/null +++ b/genpw.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +import string +import crypt +from random import * +characters = string.ascii_letters + "~@#$%^&*()-_+=23456789" + +for i in range(0,4): + password = "".join(choice(characters) for x in range(randint(10, 15))); + salt = crypt.mksalt(method=crypt.METHOD_SHA512); + print (password); + print (crypt.crypt(password,salt=salt));