This article describes how to implement a random password dictionary generator in python. if you need a dictionary generator, you can refer to all the passwords you want to use. the algorithm is either nested too deep, or memory consumption (will overflow ). later, I selected an algorithm with a low probability of simple repetition. the code is as follows:
The code is as follows:
#-*-Coding: UTF-8 -*-
'''
@ Function: generate a random password dictionary
'''
Import random
Class Dictor ():
CSet = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789 ~! @ # $ % ^ & * () _-+ =/* <>:;\ '"[] {}|'
Def _ init _ (self, minlen, maxlen ):
If maxlen> minlen:
Self. _ minlen = minlen
Self. _ maxlen = maxlen
Else:
Self. _ minlen = maxlen
Self. _ maxlen = minlen
Def _ iter _ (self ):
Return self
Def _ next _ (self ):
Ret =''
For I in range (0, random. randrange (self. _ minlen, self. _ maxlen + 1 )):
Ret + = random. choice (Dictor. CSet)
Return ret
If _ name __= = '_ main __':
For str in Dictor (6, 16 ):
Print (str)