Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!coding:utf-8
- from random import randint
- import pygtk, gtk
- pygtk.require("2.0")
- def gerarSenha(comp, mi, ma, nu, si):
- ch = mi * "abcdefghijklmnopqrstuvwxyz"\
- + ma * "ABCDEFGHIJKLMNOPQRSTUVWXYZ"\
- + nu * "1234567890"\
- + si * "!@#$%*(){}[]"
- pw = ""
- for _ in xrange(1, comp): pw += ch[randint(0, len(ch) - 1)]
- return pw
- class MainWindow:
- def __init__(self):
- self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- self.window.connect("destroy", self.destroy)
- self.window.connect("delete_event", self.delete_event)
- self.window.set_title("Pyssword")
- self.vbx_grid = gtk.VBox()
- self.hbx_tambox = gtk.HBox()
- self.hbx_chkbox = gtk.HBox()
- self.hbx_senha = gtk.HBox()
- self.lbl_tamanho = gtk.Label("Tamanho: ")
- self.hsc_comprimento = gtk.HScale()
- self.hsc_comprimento.set_range(6, 32)
- self.hsc_comprimento.set_value(16)
- self.hsc_comprimento.set_value_pos(gtk.POS_RIGHT)
- self.hsc_comprimento.set_digits(0)
- self.chk_minusculo = gtk.CheckButton("Minúsculas")
- self.chk_maiusculo = gtk.CheckButton("Maiúsculas")
- self.chk_numeros = gtk.CheckButton("Números")
- self.chk_simbolos = gtk.CheckButton("Símbolos")
- self.ent_senha = gtk.Entry(max=32)
- self.ent_senha.set_editable(False)
- self.btn_gerar = gtk.Button("Gerar")
- self.btn_gerar.connect("clicked", self.btn_gerar_click)
- self.hbx_tambox.pack_start(self.lbl_tamanho, False, False, 2)
- self.lbl_tamanho.show()
- self.hbx_tambox.pack_start(self.hsc_comprimento, True, True, 2)
- self.hsc_comprimento.show()
- self.hbx_chkbox.pack_start(self.chk_minusculo, True, True, 2)
- self.chk_minusculo.show()
- self.hbx_chkbox.pack_start(self.chk_maiusculo, True, True, 2)
- self.chk_maiusculo.show()
- self.hbx_chkbox.pack_start(self.chk_numeros, True, True, 2)
- self.chk_numeros.show()
- self.hbx_chkbox.pack_start(self.chk_simbolos, True, True, 2)
- self.chk_simbolos.show()
- self.hbx_senha.pack_start(self.ent_senha, True, True, 2)
- self.ent_senha.show()
- self.hbx_senha.pack_start(self.btn_gerar, False, False, 2)
- self.btn_gerar.show()
- self.vbx_grid.pack_start(self.hbx_tambox, True, True, 2)
- self.hbx_tambox.show()
- self.vbx_grid.pack_start(self.hbx_chkbox, True, True, 2)
- self.hbx_chkbox.show()
- self.vbx_grid.pack_start(self.hbx_senha, True, True, 2)
- self.hbx_senha.show()
- self.window.add(self.vbx_grid)
- self.vbx_grid.show()
- self.window.show()
- def main(self):
- gtk.main()
- def destroy(self, widget, data=None):
- gtk.main_quit()
- def delete_event(self, widget, event, data=None):
- return False
- def btn_gerar_click(self, widget):
- self.ent_senha.set_text(gerarSenha(\
- int(self.hsc_comprimento.get_value()),\
- self.chk_minusculo.get_active(),\
- self.chk_maiusculo.get_active(),\
- self.chk_numeros.get_active(),\
- self.chk_simbolos.get_active()))
- _w = MainWindow()
- _w.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement