Class: Xmlenc::Algorithms::AESCBC

Inherits:
Object
  • Object
show all
Defined in:
lib/xmlenc/algorithms/aes_cbc.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ AESCBC

Returns a new instance of AESCBC.



10
11
12
# File 'lib/xmlenc/algorithms/aes_cbc.rb', line 10

def initialize(size)
  @size = size
end

Class Method Details

.[](size) ⇒ Object



5
6
7
# File 'lib/xmlenc/algorithms/aes_cbc.rb', line 5

def [](size)
  new(size)
end

Instance Method Details

#decrypt(cipher_value, options = {}) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/xmlenc/algorithms/aes_cbc.rb', line 19

def decrypt(cipher_value, options = {})
  cipher.decrypt
  cipher.key = @key
  cipher.iv  = cipher_value[0...iv_len]
  result     = cipher.update(cipher_value[iv_len..-1])
  result << cipher.final
end

#setup(key) ⇒ Object



14
15
16
17
# File 'lib/xmlenc/algorithms/aes_cbc.rb', line 14

def setup(key)
  @key = key
  self
end