Skip to content

Commit

Permalink
Merge pull request geekcomputers#525 from kchittamori/master
Browse files Browse the repository at this point in the history
Sample Password Generator in Python
  • Loading branch information
geekcomputers authored Sep 28, 2019
2 parents 18241e6 + 5a7f796 commit 95374e8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions passwordGen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import random
lChars = 'abcdefghijklmnopqrstuvwxyz'
uChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits = '1234567890'
specialChars = '!@#$%^&*-_+='

passLen = 10 #actual generated password length will be this length + 1
myPass = ''

for i in range(passLen):
while(len(myPass)) <=2:
index = random.randrange(len(lChars))
myPass = myPass+lChars[index]
myPassLen = len(myPass)
while(len(myPass)) <=5:
index = random.randrange(len(digits))
myPass = myPass+digits[index]
myPassLen = len(myPass)
while(len(myPass)) <=7:
index = random.randrange(len(specialChars))
myPass = myPass+specialChars[index]
myPassLen = len(myPass)
while(len(myPass)) <=10:
index = random.randrange(len(uChars))
myPass = myPass+uChars[index]
myPassLen = len(myPass)

print(myPass)

0 comments on commit 95374e8

Please sign in to comment.