Sha256: 6bf1a8867dcf745834f35dd26a058c58b9d626e8bfca5e4919ed024e65480251
Contents?: true
Size: 990 Bytes
Versions: 8
Compression:
Stored size: 990 Bytes
Contents
module Xmlenc module Algorithms class AESCBC class << self def [](size) new(size) end end def initialize(size) @size = size end def setup(key = nil) @cipher= nil @iv = nil @key = key || cipher.random_key self end def decrypt(cipher_value, options = {}) cipher.decrypt cipher.key = @key cipher.iv = cipher_value[0...iv_len] cipher.update(cipher_value[iv_len..-1]) << cipher.final end def encrypt(data, options = {}) cipher.encrypt cipher.key = @key cipher.iv = iv iv << cipher.update(data) << cipher.final end def key @key end private def iv @iv ||= cipher.random_iv end def iv_len cipher.iv_len end def cipher @cipher ||= OpenSSL::Cipher::Cipher.new("aes-#{@size}-cbc") end end end end
Version data entries
8 entries across 8 versions & 1 rubygems