Python implementation random cipher Dictionary Generator example

Source: Internet
Author: User
Originally wanted to be poor to lift all passwords, the algorithm is either nested too deep, or special consumption of memory (will overflow). Later, a simple algorithm with very low repetition probability was chosen. The code is as follows:

Copy the Code code 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)
  • Related Article

    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.