基于python2.7实现图形密码生成器的实例代码
作者:liumt 时间:2021-01-21 15:20:50
具体代码如下所示:
#coding:utf8
import random,wx
def password(event):
a = [chr(i) for i in range(97,123)]
b = [chr(i) for i in range(65,91)]
c = ['0','1','2','3','4','5','6','7','8','9']
d = ['!','@','#','$','%','^','&','*','(',')','=','_','+','/','?']
set1 = a + b + c + d
set2 = a + b + c
num = int(length.GetValue())
if switch.GetValue() == 0:
passwd = ''.join(random.sample(set1,num))
contents.SetValue(passwd)
else:
passwd = ''.join(random.sample(set2,num))
contents.SetValue(passwd)
app = wx.App()
win = wx.Frame(None,-1,title=u'密码生成器',size=(480,200))
bkg = wx.Panel(win,-1)
# tt = wx.StaticText(bkg,-1,u'屏蔽输入字符')
# delete = wx.TextCtrl(bkg,-1)
right = wx.Button(bkg,-1,label=u'确定生成')
right.Bind(wx.EVT_BUTTON,password)
stxt = wx.StaticText(bkg,-1,u'请输入你的密码长度位数!' )
length = wx.TextCtrl(bkg,-1,size=(50,27))
switch = wx.CheckBox(bkg, -1,u'关闭特殊字符',(150, 20))
sobx = wx.BoxSizer()
sobx.Add(stxt,proportion=0,flag=wx.ALL,border=5)
sobx.Add(length,proportion=1,border=5)
sobx.Add(switch,proportion=0,flag=wx.ALL | wx.ALIGN_RIGHT,border=5)
sobx.Add(right,proportion=0,flag=wx.EXPAND,border=5)
contents = wx.TextCtrl(bkg,-1)
cobx = wx.BoxSizer()
cobx.Add(contents,proportion=1,flag=wx.EXPAND,border=5)
dobx = wx.BoxSizer()
# dobx.Add(delete,proportion=1,flag=wx.ALL,border=5)
robx = wx.BoxSizer(wx.VERTICAL)
robx.Add(cobx,proportion=1,flag=wx.EXPAND | wx.ALL,border=5)
robx.Add(sobx,proportion=0,flag=wx.ALL,border=5)
# robx.Add(dobx,proportion=0,flag=wx.EXPAND,border=5)
bkg.SetSizer(robx)
win.Show()
app.MainLoop()
ps:下面看下python密码生成器
'''
随机密码生成器
该生成器用于生成6位随机密码,包含A-Z, a-z , 0-9 , - + = @ $ % & ^
'''
import random
#定义密码生成函数
def pass_generator(n):
lst1 = list(range(65,91))
lst2 = list(range(97,123))
lst3 = list(range(10))
lst4 = ['+','-','=','@','#','$','%','^']
s1 = ''.join(chr(c) for c in lst1)
s2 = ''.join(chr(c) for c in lst2)
s3 = ''.join(str(i) for i in lst3)
s4 = ''.join( c for c in lst4)
s = s1 + s2 + s3 + s4
p = ''
for _ in range(n):
p += random.choice(s)
return p
print(pass_generator(32))
总结
以上所述是小编给大家介绍的python2.7实现图形密码生成器的实例代码网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
来源:https://www.cnblogs.com/liumt-blog/p/11791904.html
标签:python,生成器
0
投稿
猜你喜欢
Python sklearn中的K-Means聚类使用方法浅析
2022-03-16 22:01:16
python爬虫看看虎牙女主播中谁最“顶”步骤详解
2022-03-31 09:30:33
pygame实现弹力球及其变速效果
2022-12-25 16:23:07
两级联动select刷新后其值保持不变的实现方法
2023-11-05 11:39:33
python数据结构之图深度优先和广度优先实例详解
2023-05-18 20:50:15
MySQL 数据库的监控方式小结
2024-01-14 19:07:14
python学习--使用QQ邮箱发送邮件代码实例
2023-10-29 23:43:59
弹出对话框,点击跳出一个可拖动的层(对话框)
2009-09-07 12:56:00
Vue子组件内的props对象参数配置方法
2024-04-30 10:39:09
python openssl模块安装及用法
2023-07-03 12:01:04
Python跳出多重循环的方法示例
2022-12-18 16:28:26
go日志库中的logrus
2023-07-21 13:48:02
vue路由嵌套的SPA实现步骤
2024-04-28 09:20:04
python写的一个文本编辑器
2021-10-12 08:38:04
javascript的正则表达式
2010-07-27 12:29:00
JavaScript高级程序设计(第3版)学习笔记2 js基础语法
2024-06-07 15:59:19
python 自定义异常和主动抛出异常(raise)的操作
2022-03-22 12:43:22
python3+selenium实现qq邮箱登陆并发送邮件功能
2023-02-04 17:54:23
设计师的职业规划
2009-08-31 12:52:00
Flash连接服务器
2008-06-15 07:19:00