Encrypting text in ruby
Available Ciphers
Can use any of these ciphers
- blowfish
- cast
- des
- idea
- rc2
- rc4
- rc5
- dsa
- dh
- rsa
Example Code
This is How you encrypt things in ruby
To encrypt
require 'openssl'
cipher = OpenSSL::Cipher::Cipher.new( "des-ecb" )
cipher.encrypt
cipher.key = key_to_use
cipher.iv = iv_to_use
output = cipher.update( data_to_encrypt )
output << cipher.update( more_data_to_encrypt )
output << cipher.final
Or, to decrypt:
cipher = OpenSSL::Cipher::Cipher.new( "des-ecb" )
cipher.decrypt
cipher.key = key_to_use
cipher.iv = iv_to_use
output = cipher.update( data_to_dencrypt )
output << cipher.update( more_data_to_dencrypt )
output << cipher.final