Class: Xmlenc::Algorithms::AESCBC
- Inherits:
-
Object
- Object
- Xmlenc::Algorithms::AESCBC
- Defined in:
- lib/xmlenc/algorithms/aes_cbc.rb
Class Method Summary collapse
Instance Method Summary collapse
- #decrypt(cipher_value, options = {}) ⇒ Object
- #encrypt(data, options = {}) ⇒ Object
-
#initialize(size) ⇒ AESCBC
constructor
A new instance of AESCBC.
- #key ⇒ Object
- #setup(key = nil) ⇒ Object
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
21 22 23 24 25 26 |
# File 'lib/xmlenc/algorithms/aes_cbc.rb', line 21 def decrypt(cipher_value, = {}) cipher.decrypt cipher.key = @key cipher.iv = cipher_value[0...iv_len] cipher.update(cipher_value[iv_len..-1]) << cipher.final end |
#encrypt(data, options = {}) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/xmlenc/algorithms/aes_cbc.rb', line 28 def encrypt(data, = {}) cipher.encrypt cipher.key = @key cipher.iv = iv iv << cipher.update(data) << cipher.final end |
#key ⇒ Object
35 36 37 |
# File 'lib/xmlenc/algorithms/aes_cbc.rb', line 35 def key @key end |
#setup(key = nil) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/xmlenc/algorithms/aes_cbc.rb', line 14 def setup(key = nil) @cipher= nil @iv = nil @key = key || cipher.random_key self end |