本文實(shí)例講述了Python生成密碼庫功能。分享給大家供大家參考,具體如下:
這個(gè)代碼是將字符的所有組合添加到一個(gè)文件中,可以設(shè)置密碼的最大長度,我這里設(shè)置的是8位,但是要有心里準(zhǔn)備,生成的文件特別大。。。
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
下面是python的代碼:
#!/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()希望本文所述對大家Python程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選