Python实现生成密码字典的方法示例
时间:2020-11-18 06:11:28 作者:背锅熊 阅读:107次撤稿申请
key_data.py 文档储放构成数据信息,能够随时随地扩大及简单化。#coding=utf-8#!/usr/bin/pythondef year():#回到字符串类型的年代目录 year = range(1984,2018)# 常见年代目录 year_str = [] for y in year: year_str.append(str(y)) return year_strdef 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 newmlistyears = 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/pythonimport key_dataimport timedef 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 dkey_list.append(k)else:k = a b ckey_list.append(k)else:k=a bkey_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:这儿再出示几种有关专用工具供大伙儿参照应用:
在线随机数形成专用工具:
线上随机生成私人信息数据信息专用工具:
线上任意标识符/随机密码形成专用工具:
在线随机数字/字符串数组形成专用工具:
大量有关Python相关内容很感兴趣的阅读者可查询本网站专题讲座:《Python数学运算技巧总结》、《Python字符串操作技巧汇总》、《Python编码操作技巧总结》、《Python数据结构与算法教程》、《Python函数使用技巧总结》、《Python入门与进阶经典教程》及《Python文件与目录操作技巧汇总》文章内容来源于:www.seo-7.com
(责任编辑:网络)
顶一下
(0)
0%
踩一下
(0)
0%
版权声明:
1、本文由SEO内容部分来自互联网,保留著作所有权,转载请注明来源,否则谢绝转载;
2、非原创内容会有明确作者及来源标注。3、本文标题:↓↓↓Python实现生成密码字典的方法示例