Skip to content

Instantly share code, notes, and snippets.

@Elijah-trillionz
Created November 26, 2021 19:05
Show Gist options
  • Save Elijah-trillionz/f2949d0f33376d801f4c1c3699082273 to your computer and use it in GitHub Desktop.
Save Elijah-trillionz/f2949d0f33376d801f4c1c3699082273 to your computer and use it in GitHub Desktop.
password generator with python
# 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