Created
May 4, 2017 09:18
-
-
Save orsinium/0bffb29eb824cbfe6ebd11633d2072d9 to your computer and use it in GitHub Desktop.
Password generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import argv | |
from random import random, choice | |
a = 'AEIOUYaeiouy' | |
b = 'BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz' | |
try: | |
l = 10 if len(argv)<2 else int(argv[1]) | |
except: | |
print('Bad length of password!') | |
exit() | |
print('First way:') | |
for i in range(5): | |
p = '' | |
while len(p)<l: | |
p += choice(b) | |
if random()>.5: | |
p += choice(b) | |
p += choice(a) | |
print(' '+p[:l]) | |
orig = 'qwertyuiopasdfghjklzxcvbnm' | |
repl = ' 3 7 0 45 9 12 6 ' | |
words = [] | |
#p = argv[0][:argv[0].rfind('/')] | |
#if p: | |
# p += '/' | |
p = '' | |
with open(p+'words', 'r') as f: | |
for i in f: | |
words.append(i[:-1]) | |
print('Second way:') | |
for i in range(5): | |
t = '' | |
while len(t)<l: | |
t += choice(words).capitalize() | |
for a, b in zip(orig, repl): | |
if b!=' ': | |
t = t.replace(a, b) | |
print(' '+t) | |
print('Third way:') | |
for i in range(10): | |
t = '' | |
while len(t)<l: | |
t += choice(words).capitalize() | |
for a, b in zip(orig, repl): | |
if b!=' ' and random()>.5: | |
t = t.replace(a, b) | |
print(' '+t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment