python实现随机密码字典生成器示例
时间:2022-07-25 17:11:50
本来想穷举所有密码,算法要么就嵌套太深,要么就特别耗内存(会溢出).后来选了一个简单重复概率很低的算法.代码如下:
# -*- coding:utf-8 -*-
'''
@ function: 生成随机密码字典
'''
import random
class Dictor():
CSet=' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~!@#$%^&*()_-+=/*<>:;\'"[]{}|'
def __init__(self,minlen,maxlen):
if maxlen>minlen:
self.__minlen=minlen
self.__maxlen=maxlen
else:
self.__minlen=maxlen
self.__maxlen=minlen
def __iter__(self):
return self
def __next__(self):
ret=''
for i in range(0,random.randrange(self.__minlen,self.__maxlen+1)):
ret+=random.choice(Dictor.CSet)
return ret
if __name__=='__main__':
for str in Dictor(6,16):
print(str)
标签:python,密码,字典
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python 利用jieba.analyse进行 关键词提取
2021-03-16 22:11:26
![](https://img.aspxhome.com/file/2023/5/78575_0s.png)
使用element-ui +Vue 解决 table 里包含表单验证的问题
2024-05-28 16:00:02
100行Python代码实现每天不同时间段定时给女友发消息
2023-07-11 20:32:56
![](https://img.aspxhome.com/file/2023/3/82833_0s.jpg)
Python面向对象特殊属性及方法解析
2022-05-19 15:16:06
![](https://img.aspxhome.com/file/2023/3/115483_0s.png)
Python实现将数据库一键导出为Excel表格的实例
2024-01-19 19:47:27
![](https://img.aspxhome.com/file/2023/0/118360_0s.jpg)
基于FME使用Python过程图解
2023-12-17 07:57:37
![](https://img.aspxhome.com/file/2023/6/120876_0s.png)
MySQL学习之数据库操作DML详解小白篇
2024-01-14 11:59:48
MySQL GTID主备不一致的修复方案
2024-01-15 21:26:16
Python通过递归获取目录下指定文件代码实例
2021-02-24 15:08:51
关于Python的Thread线程模块详解
2022-12-20 02:48:16
![](https://img.aspxhome.com/file/2023/5/118355_0s.png)
js游戏 俄罗斯方块 源代码
2008-01-24 13:14:00
![](https://img.aspxhome.com/file/UploadPic/20081/24/200812414337986s.jpg)
python随机模块random使用方法详解
2022-07-02 04:31:10
python通过pil模块将raw图片转换成png图片的方法
2021-08-25 00:37:31
python pptx复制指定页的ppt教程
2023-08-20 22:54:50
Perl学习笔记之文件操作
2022-04-01 21:48:18
Python标准库学习之psutil内存详解
2023-09-14 21:33:35
![](https://img.aspxhome.com/file/2023/8/112138_0s.png)
用python实现一幅春联实例代码
2021-07-23 09:25:41
![](https://img.aspxhome.com/file/2023/1/133371_0s.jpg)
Python爬虫基础之XPath语法与lxml库的用法详解
2022-07-03 20:56:06
![](https://img.aspxhome.com/file/2023/3/90893_0s.png)
Python全景系列之模块与包全面解读
2022-12-09 19:26:48
Python高级架构模式知识点总结
2023-12-19 14:36:47