-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9140559
commit 8b28768
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import random | ||
import string | ||
|
||
|
||
def complex_pass(length): | ||
char1 = string.ascii_letters + string.digits + string.ascii_uppercase + string.ascii_lowercase + string.punctuation | ||
password = ''.join(random.choice(char1) for _ in range(length)) | ||
return password | ||
|
||
|
||
def mod_pass(length): | ||
char1 = string.ascii_letters + string.digits + string.punctuation | ||
password = ''.join(random.choice(char1) for _ in range(length)) | ||
return password | ||
|
||
|
||
def simple_pass(length): | ||
char1 = string.ascii_letters + string.digits | ||
password = ''.join(random.choice(char1) for _ in range(length)) | ||
return password | ||
|
||
|
||
def main(): | ||
while True: | ||
length = int(input("Enter the length of password you want: ")) | ||
if length <= 0: | ||
print("Please enter valid length") | ||
else: | ||
break | ||
complexity = input("Enter the complexity of password (complex/moderate/simple): ") | ||
if complexity == "complex": | ||
print("Your password is : ", complex_pass(length)) | ||
elif complexity == "moderate": | ||
print("Your password is : ", mod_pass(length)) | ||
elif complexity == "simple": | ||
print("Your password is : ", simple_pass(length)) | ||
else: | ||
print("Invalid Option") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |