Jump to content
Nytro

[Ruby] Encrypter md5, sha-1, Base64

Recommended Posts

Posted

Credit to protos the autor of this code

require 'digest/md5'
require 'digest/sha1'
require 'base64'
require 'tk'

root= TkRoot.new() {title "Encripter By pRotos"}

TkLabel.new(root) {
text "Palabra a Encriptar"
pack { padx 20 ; pady 20; side 'top' }
}

palabra = TkVariable.new()

TkEntry.new(root) {
textvariable(palabra)
pack()
}

TkLabel.new(root) {
text " MD5"
pack ("side"=>"bottom")
}

md5 = TkText.new(root) { width 25; height 2 }.pack("side"=>"bottom")

TkLabel.new(root) {
text "SHA1"
pack ('side'=> 'bottom')
}

sha = TkText.new(root) { width 25; height 2 }.pack("side"=>"bottom")


TkLabel.new(root) {
text "Base64"
pack ( 'side'=> 'bottom' )
}

b64 = TkText.new(root) { width 25; height 2 }.pack("side"=>"bottom")


TkButton.new(root) {
text " Encripta"
command proc {

amd5 = Digest::MD5.hexdigest(palabra.value)
asha1 = Digest::SHA1.hexdigest(palabra.value)
ab64 = Base64.encode64(palabra.value)

puts " _MD5_", amd5
puts " _SHA1_", asha1
puts " _Base64_", ab64

md5.insert('end', amd5)
sha.insert('end', asha1)
b64.insert('end', ab64)

}
pack("side"=>"top")
}

TkButton.new(root) {
text " Clear "
command proc {
md5.clear
sha.clear
b64.clear
}
pack("side"=>"bottom")
}

Tk.mainloop()

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...