module AES

Public Class Methods

decrypt(cipher_text, key, opts={}) click to toggle source

Decrypts the cipher_text with the provided key

# File lib/aes/aes.rb, line 8
def decrypt(cipher_text, key, opts={})
  ::AES::AES.new(key, opts).decrypt(cipher_text)
end
encrypt(plain_text, key, opts={}) click to toggle source

Encrypts the plain_text with the provided key

# File lib/aes/aes.rb, line 4
def encrypt(plain_text, key, opts={})
  ::AES::AES.new(key, opts).encrypt(plain_text)
end
iv(format=:plain) click to toggle source

Generates a random iv Default format is :plain

# File lib/aes/aes.rb, line 24
def iv(format=:plain)
  iv = ::AES::AES.new("").random_iv
  case format
  when :base_64
    Base64.encode64(iv).chomp
  else
    iv
  end      
end
key(length=256,format=:plain) click to toggle source

Generates a random key of the specified length in bits Default format is :plain

# File lib/aes/aes.rb, line 13
def key(length=256,format=:plain)
  key = ::AES::AES.new("").random_key(length)
  case format
  when :base_64
    Base64.encode64(key).chomp
  else
    key
  end
end