Skip to content
Snippets Groups Projects
Commit 8e92a7d9 authored by Chris Hines's avatar Chris Hines
Browse files

get_or_make_passwd.py will generate a random password and save it in a text...

get_or_make_passwd.py will generate a random password and save it in a text file, use it to make MySQL/postgres passwords or munge keys etc etc
parent 01eab218
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/python
import random
import sys
import string
def get_passwd(f,passname):
f.seek(0)
for line in f.readlines():
(key,passwd)=line.split(':')
if key==passname:
f.close()
return passwd.rstrip()
return None
def mk_passwd(f,passname):
passwd=''.join(random.choice(string.ascii_uppercase + string.digits+string.ascii_lowercase) for _ in range(16))
f.write("%s:%s\n"%(passname,passwd))
return passwd
try:
f=open('../passwd.txt','at+')
except:
f=open('./passwd.txt','at+')
passname = sys.argv[1]
passwd = get_passwd(f,passname)
if passwd == None:
passwd = mk_passwd(f,passname)
print passwd
f.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment