module Rmega::Crypto::AesCtr

Public Instance Methods

aes_ctr_cipher() click to toggle source
# File lib/rmega/crypto/aes_ctr.rb, line 4
def aes_ctr_cipher
  OpenSSL::Cipher::AES.new(128, :CTR)
end
aes_ctr_decrypt(key, data, iv) click to toggle source
# File lib/rmega/crypto/aes_ctr.rb, line 8
def aes_ctr_decrypt(key, data, iv)
  cipher = aes_ctr_cipher
  cipher.decrypt
  cipher.iv = iv
  cipher.key = key
  return cipher.update(data) + cipher.final
end
aes_ctr_encrypt(key, data, iv) click to toggle source
# File lib/rmega/crypto/aes_ctr.rb, line 16
def aes_ctr_encrypt(key, data, iv)
  cipher = aes_ctr_cipher
  cipher.encrypt
  cipher.iv = iv
  cipher.key = key
  return cipher.update(data) + cipher.final
end