Skip to content

Instantly share code, notes, and snippets.

@Code-Victor
Created February 17, 2023 16:48
Show Gist options
  • Select an option

  • Save Code-Victor/5b9f980ac3a7a059a25622c4d5997e4c to your computer and use it in GitHub Desktop.

Select an option

Save Code-Victor/5b9f980ac3a7a059a25622c4d5997e4c to your computer and use it in GitHub Desktop.
import random
LOWERCASE_ALPHABETS = "abcdefghijklmnopqrstuvwxyz"
UPPERCASE_ALPHABETS = LOWERCASE_ALPHABETS.upper()
DIGITS = "0123456789"
SPECIAL_CHARACTERS = "!@#$%^&*()_+"
PASSWORD_LENGTH = 12
lowercase_count = 3
uppercase_count = 3
digits_count = 3
special_count = 3
assert (
lowercase_count + uppercase_count + digits_count + special_count == PASSWORD_LENGTH
)
crude_password = (
"".join(random.sample(LOWERCASE_ALPHABETS, lowercase_count))
+ "".join(random.sample(UPPERCASE_ALPHABETS, uppercase_count))
+ "".join(random.sample(DIGITS, digits_count))
+ "".join(random.sample(SPECIAL_CHARACTERS, special_count))
)
password = "".join(random.sample(crude_password, len(crude_password)))
print(password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment