Python generates examples of password library functionality

  • 2020-06-01 10:21:11
  • OfStack

This article illustrates the ability of Python to generate a password library. I will share it with you for your reference as follows:

This code is to add all the combinations of characters into a file, you can set the maximum length of the password, I set 8 bits here, but be prepared, the generated file is very large...

lshuai<---~---> bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.

Here's the code for python:

import string
letters = string.letters + string.digits + string.punctuation
length = len(letters)
fwrite = open("/tmp/genpass.txt","wt")
fread = open("/tmp/genpass.txt","r")
for num in xrange(8):
    for times in xrange(length**num):
        for letter in letters:
            fwrite.write(line + letter + "\n")

PS: here are two more related online tools for you to use:

Online random number/string generation tool:

High strength password generator:

For more information about Python, please check out the topics on this site: Python data structure and algorithm tutorial, Python Socket programming skills summary, Python function skills summary, Python string manipulation skills summary, Python introduction and advanced classic tutorial and Python file and directory manipulation skills summary.

I hope this article has been helpful to you in Python programming.

Related articles: