Skip to content

Instantly share code, notes, and snippets.

@Ra1d7
Created January 31, 2017 01:01
Show Gist options
  • Save Ra1d7/5305cf47ba725260c4fbc8c18bda2958 to your computer and use it in GitHub Desktop.
Save Ra1d7/5305cf47ba725260c4fbc8c18bda2958 to your computer and use it in GitHub Desktop.
Generates a password based on user's opinion
import random
decid = input('how string do you want your password to be?(weak/medium/strong): ')
leng = int(input('how long do you want your password to be?: '))
weak = 'a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z'.split(':')
medium = '0:1:2:3:4:5:6:7:8:9'.split(':')
strong = '!:@:#:$:%:^:&:*:_:-:=:.'.split(':')
password = ''
if decid.lower() == 'weak':
while len(password) < leng:
password += weak[random.randint(0,25)]
elif decid.lower() == 'medium':
while len(password) < leng:
password += weak[random.randint(0,25)]
password += medium[random.randint(0,9)]
elif decid.lower() == 'strong':
while len(password) < leng:
password += weak[random.randint(0,25)]
password += medium[random.randint(0,9)]
password += strong[random.randint(0,11)]
print(password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment