ig-crypto-utils/lib/ig-crypto-utils.rb
# use this to generate a random (base64 encoded) AES key if required
use this to generate a random (base64 encoded) AES key if required
use this to generate a random ( base64 encoded ) AES key if required
def encrypt(encoded_plain_text, encoded_key)
      cipher = OpenSSL::Cipher::AES.new(256, :CBC) 
      cipher.encrypt
      iv = cipher.random_iv
      cipher.key = encoded_key
      cipher.iv = iv
      result = cipher.update(encoded_plain_text) + cipher.final
      encoded_result = Base64.encode64 result
      encoded_iv = Base64.encode64 iv
      {:cipher_text => encoded_result, :iv => encoded_iv}
    end
def encrypt ( encoded_plain_text , encoded_key ) cipher = OpenSSL :: Cipher :: AES . new ( 256 , :CBC ) cipher . encrypt iv = cipher . random_iv cipher . key = encoded_key cipher . iv = iv result = cipher . update ( encoded_plain_text ) + cipher . final encoded_result = Base64 . encode64 result encoded_iv = Base64 . encode64 iv { :cipher_text => encoded_result , :iv => encoded_iv } end
use this to generate a random (base64 encoded) AES key if required
use this to generate a random ( base64 encoded ) AES key if required
# CBC = cipher block chaining # generate a random iv
encoded_plain_text
<not_specific>
encoded_key
<not_specific>