Hi,
I would like to know how can we do encryption and decryption using
public
and private keys in ruby. Does ruby any RSA libraries for the same. A
small
example would be quite helpful.
Thanks
Hi,
I would like to know how can we do encryption and decryption using
public
and private keys in ruby. Does ruby any RSA libraries for the same. A
small
example would be quite helpful.
Thanks
Hi,
name pipe wrote:
Hi,
I would like to know how can we do encryption and decryption using public
and private keys in ruby. Does ruby any RSA libraries for the same. A small
example would be quite helpful.Thanks
take a look at the openssl bindings for ruby:
require “openssl”
include OpenSSL
include X509
include PKey
cert = Certificate.new(File.read(“server.cer”))
private_key = RSA.new(File.read(“server.cer.key”))
message = “This is a test!”
puts("— Start private key encryption / public key decryption")
crypt = private_key.private_encrypt(message)
puts(“Plain text ---------”)
puts(message)
puts(“Encrypted text------”)
puts(crypt)
puts(“Decryted text-------”)
puts(cert.public_key.public_decrypt(crypt))
puts("— Start public key encryption / private key decryption")
crypt = cert.public_key.public_encrypt(message)
puts(“Encrypted text------”)
puts(crypt)
puts(“Decryted text-------”)
puts(private_key.private_decrypt(crypt))
Regards,
Roland
Thanks, but its bit confusing with new include files and stuff. Any
simple
eg. which creates RSA public, private keys and encrypts/decrypts data ?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs