Password generation in texto with python

The string module defines a set of characters in various categories.

console


>>> import string
>>> string.ascii_letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> string.ascii_uppercase
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> string.ascii_lowercase
'abcdefghijklmnopqrstuvwxyz'
>>> string.digits
'0123456789'
>>> string.punctuation
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
>>> string.whitespace
'\t\n\x0b\x0c\r '
>>> string.printable
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c'

Let's use this to generate a password for Tekito.

console


>>> import random, string
#For 4-letter numbers
>>> ''.join([random.choice(string.digits) for i in range(4)])
'7602'
>>> ''.join([random.choice(string.digits) for i in range(4)])
'7531'

#For 8 alphanumeric characters
>>> ''.join([random.choice(string.ascii_letters + string.digits) for i in range(8)])
'84xemCAc'
>>> ''.join([random.choice(string.ascii_letters + string.digits) for i in range(8)])
'cjiGNd2k'

#For 12-character alphanumeric symbols
>>> ''.join([random.choice(string.punctuation + string.ascii_letters + string.digits) for i in range(12)])
'9f58EN+}rbW8'
>>> ''.join([random.choice(string.punctuation + string.ascii_letters + string.digits) for i in range(12)])
'DP4E,N}jtT;W'

You can change the length and type of characters as needed, so you can use it in addition to passwords. maybe? It's annoying to hit the interactive shell every time, so I thought it would be better to use the ʻargparse` module or something to hit from the shell.

Recommended Posts

Password generation in texto with python
Experiment with NIST 800-63B password rules in Python
Working with LibreOffice in Python
Scraping with chromedriver in python
Working with sounds in Python
Scraping with Selenium in Python
Scraping with Tor in Python
Combined with permutations in Python
Easy password box in Python
Password management with python: keyring
Testing with random numbers in Python
GOTO in Python with Sublime Text 3
Working with LibreOffice in Python: import
Scraping with Selenium in Python (Basic)
Basic authentication with an encrypted password (.htpasswd) in bottle with python
Numer0n with items made in Python
Open UTF-8 with BOM in Python
Use rospy with virtualenv in Python3
Use Python in pyenv with NeoVim
[Python] Generate a password with Slackbot
CSRF countermeasure token generation with Python
Use OpenCV with Python 3 in Window
Until dealing with python in Atom
Get started with Python in Blender
Working with DICOM images in Python
Gradation image generation with Python [1] | np.linspace
Write documentation in Sphinx with Python Livereload
Get additional data in LDAP with python
Spiral book in Python! Python with a spiral book! (Chapter 14 ~)
Try logging in to qiita with Python
Python3> in keyword> True with partial match?
Exclusive control with lock file in Python
Device monitoring with On-box Python in IOS-XE
Try working with binary data in Python
Draw Nozomi Sasaki in Excel with python
Tips for dealing with binaries in Python
Display Python 3 in the browser with MAMP
Page cache in Python + Flask with Flask-Caching
Post Test 3 (Working with PosgreSQL in Python)
How to work with BigQuery in Python
Playing card class in Python (with comparison)
Simplify PDF password unlock with python + bat
Dealing with "years and months" in Python
Process multiple lists with for in Python
Replace non-ASCII with regular expressions in Python
Connect with mysql.connector with ssh tunnel in Python 3.7
One liner webServer (with CGI) in python
Get Started with TopCoder in Python (2020 Edition)
Call sudo in Python and autofill password
Easy image processing in Python with Pillow
To work with timestamp stations in Python
Call APIGateWay with APIKey in python requests
I created a password tool in Python.
Read text in images with python OCR
Introduced sip-4.14 in python3.2.2 environment with MacOS 10.7.4
Quadtree in Python --2
Python in optimization
CURL in python
FizzBuzz with Python3
Metaprogramming in Python
Python 3.3 in Anaconda