Example of a random password dictionary generator implemented in python

Source: Internet
Author: User
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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.