python编写破解密码字典
用到的模块是python自带的itertools模块
有以下几个函数:
count()函数:产生递增序列,eg count(1,5),生成从1开始的循环器,每次增加5,即1,6,11,...。
repeat()函数:重复元素,构成无穷循环器,eg repeat(100),即100,100,100,...。
cycle()函数:重复序列中的元素,例如cycle('hello'),将序列中的元素重复,即h,e,l,l,o,h,e,l,l,0...。
product()函数:用来获得多个循环器的笛卡尔积,eg product('xyz',[1,2])得到的结果是x1,x2,y1,y2,z1,z2。
permutations(’abcd',2):从‘abcd’中选2个元素,将所有结果排序,返回为新的循环器。这些元素中的组合是有顺序的,同时生成cd和dc。
combinations('abcd',2):从‘abcd’中选2个元素,将所有结果排序,返回为新的循环器。这些元素中的组合是没有顺序的,‘c’和‘d’只生成cd。
import itertools
items = '1234567890qwertyuiopasdfghjklzxcvbnm'
password = itertools.product(items, repeat=6)
with open('password6.txt', 'w', encoding='utf8') as f:
for i, j in enumerate(password):
print(f'产生第{i+1}个密码')
f.write(''.join(j))
f.write(''.join('\n'))

浙公网安备 33010602011771号