Created
November 26, 2021 19:05
-
-
Save Elijah-trillionz/f2949d0f33376d801f4c1c3699082273 to your computer and use it in GitHub Desktop.
password generator with python
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
# password generator | |
import random as rd | |
alphabets = 'abcdefghijklmnopqrstuvwxyz' | |
numbers = '1234567890' | |
characters = '!@#$%^&*~' | |
def generate_random_char(): | |
alphabets_upper = alphabets.upper() | |
chars = alphabets_upper + numbers + characters + alphabets | |
# generating a random character btw 1 and length of all characters and returning it | |
return chars[rd.randint(1, len(chars)-1)] | |
def generate_password(length=16): | |
i = 0 | |
password = '' | |
while i < length: | |
char = generate_random_char() | |
password += char | |
i += 1 | |
print(password) | |
generate_password() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment