基于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í)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(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)文章
完美解決Python matplotlib繪圖時(shí)漢字顯示不正常的問題
今天小編就為大家分享一篇完美解決Python matplotlib繪圖時(shí)漢字顯示不正常的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-01-01
python實(shí)現(xiàn)mysql的讀寫分離及負(fù)載均衡
這篇文章主要介紹了python實(shí)現(xiàn)mysql的讀寫分離及負(fù)載均衡 ,需要的朋友可以參考下2018-02-02
一文帶你精通Python中exec函數(shù)的高級(jí)技巧
在?Python?中,exec?是一個(gè)內(nèi)置函數(shù),允許在運(yùn)行時(shí)動(dòng)態(tài)執(zhí)行?Python?代碼,本文將詳細(xì)介紹?Python?exec?函數(shù)的高級(jí)用法,包括動(dòng)態(tài)代碼生成、執(zhí)行外部文件等內(nèi)容,希望對(duì)大家有所幫助2023-11-11
Python錯(cuò)誤提示:[Errno 24] Too many open files的分析與解決
這篇文章主要給大家介紹了Python中出現(xiàn)錯(cuò)誤提示:[Errno 24] Too many open files的分析與解決,需要的朋友可以參考借鑒,下面來一起看看吧。2017-02-02
解決pytorch中的kl divergence計(jì)算問題
這篇文章主要介紹了解決pytorch中的kl divergence計(jì)算問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-05-05
簡單學(xué)習(xí)Python多進(jìn)程Multiprocessing
這篇文章主要和大家一起簡單的學(xué)習(xí)Python多進(jìn)程Multiprocessing ,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-08-08
python中windows鏈接linux執(zhí)行命令并獲取執(zhí)行狀態(tài)的問題小結(jié)
這篇文章主要介紹了python中windows鏈接linux執(zhí)行命令并獲取執(zhí)行狀態(tài),由于工具是pyqt寫的所以牽扯到用python鏈接linux的問題,這里記錄一下一些碰到的問題,需要的朋友可以參考下2022-11-11

