import threading
import string

# 密码长度
length = 6

# 密码字符集
charset = string.ascii_letters + string.digits

# 打开文件
f = open('password.txt', 'w+')

# 线程池
threads = []

# 生成密码
def generate_password(pwd):
    # 密码生成完毕
    if len(pwd) == length:
        f.write(''.join(pwd) + '
')
    else:
        for c in charset:
            pwd.append(c)
            generate_password(pwd)
            pwd.pop()

if __name__ == '__main__':
    for i in range(length):
        t = threading.Thread(target=generate_password, args=([i]))
        threads.append(t)
    for t in threads:
        t.start()
    for t in threads:
        t.join()
    # 关闭文件
f.close()
Python 多线程密码字典生成脚本:快速生成密码组合

原文地址: https://www.cveoy.top/t/topic/lh18 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录