Criei um gerador de senhas.

https://video.nostr.build/2d462bd739ec9786c9313ffd02c4969b7ea5972d82432e8372a7241bdf871cf5.mp4

Reply to this note

Please Login to reply.

Discussion

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