python密码字典生成库_Python生成MD5密码字典库

该博客介绍了如何使用Python创建一个密码字典生成库,通过组合不同字符生成指定长度的密码,然后进行MD5、Base64等哈希运算,并将结果保存到TXT文件中。主要涉及的步骤包括定义字符集、生成密码组合、计算哈希值以及写入文件。
摘要由CSDN通过智能技术生成

功能介绍:

把虽有的字符作为密码种子

然后拼接成指定长度的密码

再进行hash base64 等操作

最后把结果保存在一个TXT文档里面

思路:

1.得到组成字典的字符 words

2.根据长度和words 组成密码

3.进行hash计算并保存结果

#-* coding: utf-8 -*

import hashlib

import base64

import itertools as its

import os

reload(sys)

chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

specialChars = '~!@#$%^&*()_+{}|:"<>?`-=[]\;\',./'

numbers = "1234567890"

words = chars + specialChars + numbers

def get_FileSize(filePath):

filePath = unicode(filePath,'utf8')

if os.path.isfile(filePath):

fsize = os.path.getsize(filePath)

fsize = fsize / float(1024 * 1024)

return round(fsize, 2)

return 0

def MD5(s):

m2 = hashlib.md5()

m2.update(s)

return m2.hexdigest()

def write2File(p,s):

f = open(p, 'a')

f.write(s)

f.close()

filePath = '/Users/MacOS/Documents/'

def createHash(cs,lenth):

r =its.product(cs,repeat=lenth)

fileIndex = 0

for i in r:

str_plaintext = ''.join(i) #明文

str_md5_32 = MD5(str_plaintext)

str_md5_16 = str_md5_32[8:24]

str_md5_32_md5_32 = MD5(str_md5_32)

str_md5_32_md5_16 = str_md5_32_md5_32[8:24]

str_md5_16_md5_32 = MD5(str_md5_16)

str_md5_16_md5_16 = str_md5_16_md5_32[8:24]

str_md5_16_base64 = base64.b64encode(str_md5_16)

str_md5_16_base64_md5_32 = MD5(str_md5_16_base64)

str_md5_16_base64_md5_16 = str_md5_16_base64_md5_32[8:24]

str_md5_32_base64 = base64.b64encode(str_md5_32)

str_md5_32_base64_md5_32 = MD5(str_md5_32_base64)

str_md5_32_base64_md5_16 = str_md5_32_base64_md5_32[8:24]

# Base64

str64 = base64.b64encode(str_plaintext)

str64_md5_32 = MD5(str64)

str64_md5_16 = str64_md5_32[8:24]

str64_md5_32_MD5_32 = MD5(str64_md5_32)

str64_md5_32_MD5_16 = str64_md5_32_MD5_32[8:24]

str64_md5_16_MD5_32 = MD5(str64_md5_16)

str64_md5_16_MD5_16 = str64_md5_16_MD5_32[8:24]

str64_md5_16_base64 = base64.b64encode(str64_md5_16)

str64_md5_16_base64_md5_32 = MD5(str64_md5_16_base64)

str64_md5_16_base64_md5_16 = str64_md5_16_base64_md5_32[8:24]

str64_md5_32_base64 = base64.b64encode(str64_md5_32)

str64_md5_32_base64_md5_32 = MD5(str64_md5_32_base64)

str64_md5_32_base64_md5_16 = str64_md5_32_base64_md5_32[8:24]

'''

Save 2 File

'''

fileName = str(lenth) + '_' + str(fileIndex) + '.txt'

fileSize = get_FileSize(filePath + fileName)

if fileSize > 10 * 1024:# 10G

fileIndex = fileIndex + 1

fileName = str(lenth) + '_' + str(fileIndex) + '.txt'

values = \

str_plaintext + \

' ' + str_md5_32 + \

' ' + str_md5_16 + \

' ' + str_md5_32_md5_32 + \

' ' + str_md5_32_md5_16 + \

' ' + str_md5_16_md5_32 + \

' ' + str_md5_16_md5_16 + \

' ' + str_md5_16_base64 + \

' ' + str_md5_16_base64_md5_32 + \

' ' + str_md5_16_base64_md5_16 + \

' ' + str_md5_32_base64 + \

' ' + str_md5_32_base64_md5_32 + \

' ' + str_md5_32_base64_md5_16 + \

' ' + str64 + \

' ' + str64_md5_32 + \

' ' + str64_md5_16 + \

' ' + str64_md5_32_MD5_32 + \

' ' + str64_md5_32_MD5_16 + \

' ' + str64_md5_16_MD5_32 + \

' ' + str64_md5_16_MD5_16 + \

' ' + str64_md5_16_base64 + \

' ' + str64_md5_16_base64_md5_32 + \

' ' + str64_md5_16_base64_md5_16 + \

' ' + str64_md5_32_base64 + \

' ' + str64_md5_32_base64_md5_32 + \

' ' + str64_md5_32_base64_md5_16

write2File(filePath + fileName, values+'\n')

createHash(words,4)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值