class Xmlenc::Algorithms::DES3CBC

Public Class Methods

new(key = nil) click to toggle source
# File lib/xmlenc/algorithms/des3_cbc.rb, line 8
def initialize(key = nil)
  @key = key || cipher.random_key
end
setup(key) click to toggle source
# File lib/xmlenc/algorithms/des3_cbc.rb, line 4
def self.setup(key)
  new(key)
end

Public Instance Methods

decrypt(cipher_value, options = {}) click to toggle source
# File lib/xmlenc/algorithms/des3_cbc.rb, line 12
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
encrypt(data, options = {}) click to toggle source
# File lib/xmlenc/algorithms/des3_cbc.rb, line 19
def encrypt(data, options = {})
  cipher.encrypt
  cipher.key = @key
  cipher.iv  = iv
  iv << cipher.update(data) << cipher.final
end
key() click to toggle source
# File lib/xmlenc/algorithms/des3_cbc.rb, line 26
def key
  @key
end

Private Instance Methods

cipher() click to toggle source
# File lib/xmlenc/algorithms/des3_cbc.rb, line 36
def cipher
  @cipher ||= OpenSSL::Cipher.new('des-ede3-cbc')
end
iv_len() click to toggle source
# File lib/xmlenc/algorithms/des3_cbc.rb, line 32
def iv_len
  cipher.iv_len
end