python 密码库_python生成密码库

2.[文件]

passwordGenerate.py ~ 4KB

下载(13)

# -*- coding: cp936 -*-

import string

import threading

import random

import os.path

LOCK = threading.Lock()

PC = string.ascii_letters+\

string.digits+\

r"+-*/=,.;'\[]`"

TOTAL = 0

FILENAME_CHARACTER = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

def filenameGenerate():

global FILENAME_CHARACTER,FILE

filename = ''

while True:

filename = random.sample(FILENAME_CHARACTER,random.randint(0,10))

tmp = ''

for i in filename:

tmp = tmp + i

filename = tmp

if os.path.exists("password\\"+filename) == False:

break

else:

continue

return filename

FILENAME = filenameGenerate()

def func(password):

print password

global LOCK,TOTAL,FILENAME,FILE

if LOCK.acquire(1):

if TOTAL % 1000 == 0:

FILENAME = filenameGenerate()

f = open("password\\"+FILENAME,'a')

f.write(password+'\n')

f.flush()

f.close()

TOTAL = TOTAL + 1

LOCK.release()

def func1(func):

global PC

for i in range(0,len(PC)):

tmp = str(PC[i])

func(tmp)

def func2(func):

global PC

for i1 in range(0,len(PC)):

for i2 in range(0,len(PC)):

tmp = str(PC[i1])+str(PC[i2])

func(tmp)

def func3(func):

global PC

for i1 in range(0,len(PC)):

for i2 in range(0,len(PC)):

for i3 in range(0,len(PC)):

tmp = str(PC[i1])+str(PC[i2]) + str(PC[i3])

func(tmp)

def func4(func):

global PC

for i1 in range(0,len(PC)):

for i2 in range(0,len(PC)):

for i3 in range(0,len(PC)):

for i4 in range(0,len(PC)):

tmp = str(PC[i1])+str(PC[i2]) + str(PC[i3])+str(PC[i4])

func(tmp)

def func5(func):

global PC

for i1 in range(0,len(PC)):

for i2 in range(0,len(PC)):

for i3 in range(0,len(PC)):

for i4 in range(0,len(PC)):

for i5 in range(0,len(PC)):

tmp = str(PC[i1])+str(PC[i2]) + str(PC[i3])+str(PC[i4])+str(PC[i5])

func(tmp)

def func6(func):

global PC

for i1 in range(0,len(PC)):

for i2 in range(0,len(PC)):

for i3 in range(0,len(PC)):

for i4 in range(0,len(PC)):

for i5 in range(0,len(PC)):

for i6 in range(0,len(PC)):

tmp = str(PC[i1])+str(PC[i2]) + str(PC[i3])+str(PC[i4])+str(PC[i5])+str(PC[i6])

func(tmp)

if __name__ == '__main__':

group = []

#group.append(threading.Thread(target=func1,args=(func,)))

#group.append(threading.Thread(target=func2,args=(func,)))

#group.append(threading.Thread(target=func3,args=(func,)))

group.append(threading.Thread(target=func4,args=(func,)))

#group.append(threading.Thread(target=func5,args=(func,)))

#group.append(threading.Thread(target=func6,args=(func,)))

for i in group:

i.start()

while True:

error = 0

for i in group:

if i.isAlive() == False:

error = error + 1

if error == len(group):

break

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值