Function example for generating a password library in Python and example for generating a password in python
This example describes how to generate a password library in Python. We will share this with you for your reference. The details are as follows:
This Code adds all combinations of characters to a file. You can set the maximum length of the password. I have set 8 characters here, but be prepared, the generated file is very large...
lshuai<---~---> bcbc 1.06.95Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.This is free software with ABSOLUTELY NO WARRANTY.For details type `warranty'.(95*2+95^2*3+95^3*4+95^4*5+95^5*6+95^6*7+95^7*8+95^8*9)/1024/1024/102456132395
The following is the python code:
#!/usr/bin/pythonimport stringletters = string.letters + string.digits + string.punctuationlength = 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): line=fread.read(num+1).rstrip() for letter in letters: fwrite.write(line + letter + "\n") fwrite.flush()fwrite.close()fread.close()
PS: Here are two related online tools for your reference:
Online random number/string generation tool:
Http://tools.jb51.net/aideddesign/suijishu
High-strength Password generator:
Http://tools.jb51.net/password/CreateStrongPassword