码迷,mamicode.com
首页 > 编程语言 > 详细

python2.7写的图形密码生成器

时间:2019-11-04 15:20:24      阅读:53      评论:0      收藏:0      [点我收藏+]

标签:生成   for   sam   rand   main   rop   and   amp   tle   

#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()




python2.7写的图形密码生成器

标签:生成   for   sam   rand   main   rop   and   amp   tle   

原文地址:https://www.cnblogs.com/liumt-blog/p/11791904.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!