您好,登錄后才能下訂單哦!
python2.7實(shí)現(xiàn)圖形密碼生成器?很多新手對此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
具體代碼如下所示:
#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'請輸入你的密碼長度位數(shù)!' ) length = wx.TextCtrl(bkg,-1,size=(50,27)) switch = wx.CheckBox(bkg, -1,u'關(guān)閉特殊字符',(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密碼生成器
''' 隨機(jī)密碼生成器 該生成器用于生成6位隨機(jī)密碼,包含A-Z, a-z , 0-9 , - + = @ $ % & ^ ''' import random #定義密碼生成函數(shù) 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))
看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進(jìn)一步的了解或閱讀更多相關(guān)文章,請關(guān)注億速云行業(yè)資訊頻道,感謝您對億速云的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。