Skip to content

Create password_generator.py #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions scripts/password_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import random
import string
import sys
Green = "\033[32m"
Blue = "\034[40m"
End = "\033[0m"
Red = "\033[31m"
specialChars = "!@#$%^&*-_+="
all = string.ascii_letters + string.digits + specialChars



def passowrd_generator(number):
password = []
for i in range(number):
for j in random.choice(all):
password.append(j)
return "".join(x for x in password)

def validate_password(result):
Upper = 0
Lower = 0
digits = 0
special_characters = 0
for i in result:
if i.isupper() == True:
Upper += 1
elif i.islower() == True:
Lower += 1
elif i in specialChars:
special_characters += 1
elif i.isdigit() == True:
digits += 1
if Upper and Lower and special_characters and digits >=1:
print(Green + "{} passowrd is good ".format(result) +End)
else:
print(Red+ "{} is not a good passowrd. It does not contain all the requirments. Rerun the script again".format(result) + End)

if __name__ == "__main__":
number = int(raw_input("enter the number : "))
if number < 4:
print("provide the number greater or equal to 4")
sys.exit(0)


result = passowrd_generator(number)
validate_password(result)