Venoxo's avatar
Venoxo 1 week ago
Criei um gerador de senhas.

Replies (1)

Venoxo's avatar
Venoxo 1 week ago
Esse é o código require "gtk3" def gerar_senha(tamanho) caracteres = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*" senha = "" tamanho.times do senha << caracteres.chars.sample end senha end # Janela window = Gtk::Window.new("Gerador de Senhas") window.set_border_width(10) window.set_default_size(300, 100) # Layout vertical box = Gtk::Box.new(:vertical, 10) window.add(box) # Campo de texto entry = Gtk::Entry.new entry.editable = false box.pack_start(entry, expand: true, fill: true, padding: 0) # Botão button = Gtk::Button.new(label: "Gerar senha") button.signal_connect("clicked") do entry.text = gerar_senha(12) end box.pack_start(button, expand: false, fill: false, padding: 0) # Fechar programa window.signal_connect("destroy") { Gtk.main_quit } window.show_all Gtk.main