本文实例讲述了Python实现生成密码字典的方法。分享给大家供大家参考,具体如下:
key_data.py 文件存放组成数据,可以随时扩充及简化。
#coding=utf-8 #!/usr/bin/python def year():#返回字符串类型的年份列表 year = range(1984,2018)# 常用年份列表 year_str = [] for y in year: year_str.append(str(y)) return year_str def month_or_day(n):#生成字符串类型的月份、日期 mlist = range(1,n+1) newmlist =[] for i in mlist: m = '0'*(2-int(len(str(i))))+str(i) newmlist.append(m) return newmlist years = year()#常用年份 months = month_or_day(12) #所有月份 days = month_or_day(31) #所有日期 most_str = ['!','*','#','_','.','@']# 常用特殊符号 #常见姓氏 first_name = ['li','ma','wu','xu','hu','tan','he','liu','sun','gao','luo','zheng','guo', 'zhu','wang','zhao','yang','zhou','song','deng','zhang','huang','liang'] #常见名字 second_name = [ 'bo','bi','bai','bei','bao','ban','bin','bang','bing','biao', 'ci','cai','can','cen','cun','ceng','cong','che','chi','chu','chao','chan','chen','chong','chuang', 'de','di','du','dai','dao','dan','dong','ding', 'fa','fu','fei','fan','fen','feng','fang', 'gu','gui','gan','gen','guo','gang','geng','guan','guang', 'hui','hao','han','huo','hang','heng','huan','huang', 'ji','ju','jiu','jie','jun','jue','jing','jia','jiao','jian','juan','jiang','jin', 'kai','kui','kan','kun','kuo','kang','kong', 'le','li','lu','lai','lei','lan','lin','lang','ling','long','liao','lian','luan', 'mi','mu','mai','mei','mao','man','min','mang','meng','ming','miao','mian', 'na','ni','niu','nan','nuo','neng','ning', 'pi','pu','pai','pei','pan','pin','pang','peng','ping','pian', 'qi','qiu','qing','qiang','quan','qian', 'si','su','sai','suo','sang','song','sha','shi','shu','shao','shou','shan','shang','shen','shuo','shuang', 'ta','te','ti','tu','tai','tao','tan','tuo','tang','teng','ting','tong','tian', 'wa','wei','wang','wan','wen' 'xi','xu','xie','xin','xun','xue','xing','xiang','xiong','xia','xian','xuan', 'ya','yi','yu','yao','you','yan','yun','yue','ying','yang','yong','yuan', 'zao','zan','zun','zuo','zeng','zong','zhi','zhou','zhan','zhen','zhong','zhuan','zhuang', ] #常用密码 common_key = ['11111111','00000000','11223344','0123456789','147258369','66666666','123123123', '88888888','12341234','88889999','11112222','a1b2c3d4','22222222','99999999','999999999', '1111111111','77777777','23456789','1122334455','55555555','qwertyuiop','8888888888', '12345687','012345678','abcd1234','a123456789','0000000000','12344321','123321123'] #常用密码字符 common_str = ['admin','china','love','110','asd','123456','super','0101','666','666666','888','888888','abc','fuck']
代码文件。根据实际需要,决定组合方式。
#coding=utf-8 #!/usr/bin/python import key_data import time def file_edit(wr_str):#存入txt文件 f1 = open(r'D:\python\key.txt','a') f1.write(wr_str) f1.close() def write_to_file(w_list):#把列表中长度大于7的元素写入txt文件 for i in w_list: if len(i)>7: file_edit(i+","+"\n") def make_key(list1,list2,list3=[],list4=[]):#密码组合,支持2--4种任意组合 key_list = [] for a in list1: for b in list2: if list3: for c in list3: if list4: for d in list4: k = a+b+c+d key_list.append(k) else: k = a+b+c key_list.append(k) else: k=a+b key_list.append(k) return key_list #key_list0 = key_data.common_key # 常用密码 #key_list1 = make_key(key_list0,key_data.most_str)#常用密码+特殊字符 #key_list2 = make_key(key_data.first_name,key_data.months,key_data.days)#姓+月+日 #key_list3 = make_key(key_data.first_name,key_data.months,key_data.days,key_data.most_str)#姓+月+日+特殊字符 #key_list4 = make_key(key_data.months,key_data.days,key_data.first_name)#月+日+姓 #key_list5 = make_key(key_data.first_name,key_data.common_str)#姓+常用字符 #key_list6 = make_key(key_data.first_name,key_data.second_name,key_data.years) #姓+名+年 #key_list7 = make_key(key_data.common_str,key_data.common_str) #常用字符+常用字符 #key_list8 = make_key(key_data.common_str,key_data.common_str,key_data.most_str) #常用字符+常用字符+特殊字符 #key_list9 = make_key(key_data.common_str,key_data.years) #常用字符+年 #key_list10 = make_key(key_data.second_name,key_data.second_name,key_data.months,key_data.days)#名+名+月+日 if __name__=='__main__': #开始生成密码文件 write_to_file(key_list0) time.sleep(1) write_to_file(key_list1) time.sleep(1) write_to_file(key_list2) time.sleep(1) write_to_file(key_list3) print "done"
PS:这里再提供几款相关工具供大家参考使用:
在线随机数生成工具:
http://tools.jb51.net/aideddesign/rnd_num
在线随机生成个人信息数据工具:
http://tools.jb51.net/aideddesign/rnd_userinfo
在线随机字符/随机密码生成工具:
http://tools.jb51.net/aideddesign/rnd_password
在线随机数字/字符串生成工具:
http://tools.jb51.net/aideddesign/suijishu
更多关于Python相关内容感兴趣的读者可查看本站专题:《Python数学运算技巧总结》、《Python字符串操作技巧汇总》、《Python编码操作技巧总结》、《Python数据结构与算法教程》、《Python函数使用技巧总结》、《Python入门与进阶经典教程》及《Python文件与目录操作技巧汇总》
希望本文所述对大家Python程序设计有所帮助。
标签:
Python,生成密码字典
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“Python实现生成密码字典的方法示例”评论...
更新动态
2024年11月25日
2024年11月25日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]