基于python2.7實(shí)現(xiàn)圖形密碼生成器的實(shí)例代碼
具體代碼如下所示:
#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))
總結(jié)
以上所述是小編給大家介紹的python2.7實(shí)現(xiàn)圖形密碼生成器的實(shí)例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
- python如何隨機(jī)生成高強(qiáng)度密碼
- python隨機(jī)生成大小寫字母數(shù)字混合密碼(僅20行代碼)
- Python實(shí)現(xiàn)生成密碼字典的方法示例
- python利用itertools生成密碼字典并多線程撞庫破解rar密碼
- python 隨機(jī)生成10位數(shù)密碼的實(shí)現(xiàn)代碼
- python 腳本生成隨機(jī) 字母 + 數(shù)字密碼功能
- Python生成隨機(jī)密碼的方法
- Python簡單生成8位隨機(jī)密碼的方法
- Python編程生成隨機(jī)用戶名及密碼的方法示例
- 用python寫一個(gè)帶有g(shù)ui界面的密碼生成器
相關(guān)文章
解決一個(gè)pandas執(zhí)行模糊查詢sql的坑
這篇文章主要介紹了解決一個(gè)pandas執(zhí)行模糊查詢sql的坑,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-03-03Python Arrow處理時(shí)間數(shù)據(jù)使用詳解(標(biāo)準(zhǔn)庫之外另一種選擇)
這篇文章主要介紹了Python標(biāo)準(zhǔn)庫之外Arrow處理時(shí)間數(shù)據(jù)的另一種選擇使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2024-01-01python高溫預(yù)警數(shù)據(jù)獲取實(shí)例
這篇文章主要為大家介紹了利用python獲取高溫?cái)?shù)據(jù)進(jìn)行高溫預(yù)警的防護(hù)措施,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07Python socket模塊方法實(shí)現(xiàn)詳解
這篇文章主要介紹了Python socket模塊方法實(shí)現(xiàn)詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-11-11Pytorch上下采樣函數(shù)之F.interpolate數(shù)組采樣操作詳解
最近用到了上采樣下采樣操作,pytorch中使用interpolate可以很輕松的完成,下面這篇文章主要給大家介紹了關(guān)于Pytorch上下采樣函數(shù)之F.interpolate數(shù)組采樣操作的相關(guān)資料,需要的朋友可以參考下2022-04-04