Crypto in ruby 1
Nick asked on ruby-talk how to do simple encryption using ruby and it’s built in OpenSSL module.
I’ve just registred an ezcrypto module at rubyforge, which should make it a lot easier to use. There currently is no code there, but I will be uploading something shortly.
However to get started here is a little starter:
require 'openssl'
require 'digest/sha2'
cipher = OpenSSL::Cipher::Cipher.new('aes-192-cbc')
cipher.encrypt
cipher.key=Digest::SHA256.digest("super secret password")
encrypted= cipher<<"data to be encrypted..." # Note this needs to be padded to be the block size of the cipher.
To do decrypt just use cipher.decrypt instead.
Create, negotiate and accept legally binding contracts for free with our Agree2 service.
Trackbacks
Use the following link to trackback from your own site:
http://stakeventures.com/articles/trackback/32





Hey,
do you actually know if it is possible to have multiple signing keys thus allowing multiple users toi decrypt a model in ezcrypto?
Regards
Timo&*