Class: Xmlenc::Algorithms::DES3CBC
- Inherits:
-
Object
- Object
- Xmlenc::Algorithms::DES3CBC
- Defined in:
- lib/xmlenc/algorithms/des3_cbc.rb
Class Method Summary collapse
Instance Method Summary collapse
- #decrypt(cipher_value, options = {}) ⇒ Object
- #encrypt(data, options = {}) ⇒ Object
-
#initialize(key = nil) ⇒ DES3CBC
constructor
A new instance of DES3CBC.
- #key ⇒ Object
Constructor Details
#initialize(key = nil) ⇒ DES3CBC
Returns a new instance of DES3CBC.
8 9 10 |
# File 'lib/xmlenc/algorithms/des3_cbc.rb', line 8 def initialize(key = nil) @key = key || cipher.random_key end |
Class Method Details
.setup(key) ⇒ Object
4 5 6 |
# File 'lib/xmlenc/algorithms/des3_cbc.rb', line 4 def self.setup(key) new(key) end |
Instance Method Details
#decrypt(cipher_value, options = {}) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/xmlenc/algorithms/des3_cbc.rb', line 12 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
19 20 21 22 23 24 |
# File 'lib/xmlenc/algorithms/des3_cbc.rb', line 19 def encrypt(data, = {}) cipher.encrypt cipher.key = @key cipher.iv = iv iv << cipher.update(data) << cipher.final end |
#key ⇒ Object
26 27 28 |
# File 'lib/xmlenc/algorithms/des3_cbc.rb', line 26 def key @key end |