An Interest In:
Web News this Week
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
March 13, 2021 04:00 pm GMT
Original Link: https://dev.to/zsoltszakal/simplest-python-random-password-with-only-6-lines-of-code-4mnc
Simplest Python Random Password - with only 6 lines of code
The most simple way to generate a random password in Python.
- import string
- import random
- with string create possible charachters
- with random generate a random number
- create password
- print password to the console
import stringimport randompassword_chars = string.ascii_letters + string.digits + string.punctuationlength = random.randint(12, 15)password = "".join([random.choice(password_chars) for _ in range(length)])print(password)
Or a single line password generator below:
import stringimport randomprint("".join([random.choice(string.ascii_letters + string.digits + string.punctuation) for _ in range(random.randint(12, 15))]))
Original Link: https://dev.to/zsoltszakal/simplest-python-random-password-with-only-6-lines-of-code-4mnc
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To