added genpw.py

This commit is contained in:
xpk
2019-01-21 21:43:32 +08:00
parent 0f44dd5761
commit c3e7d642fb
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -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.
+11
View File
@@ -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));