Sha256: e2b1f33e827ec177d6c10821661b9f6187010946719ae7962cfbd2ed9857103d

Contents?: true

Size: 789 Bytes

Versions: 23

Compression:

Stored size: 789 Bytes

Contents

module Xmlenc
  module Algorithms
    class DES3CBC
      def self.setup(key)
        new(key)
      end

      def initialize(key = nil)
        @key = key || cipher.random_key
      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_len
        cipher.iv_len
      end

      def cipher
        @cipher ||= OpenSSL::Cipher::Cipher.new('des-ede3-cbc')
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
xmlenc-0.6.9 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.6.8 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.6.6 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.6.5 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.6.4 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.6.3 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.6.2 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.6.1 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.6.0 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.5.0 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.4.1 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.4.0 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.3.0 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.2.1 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.2.0 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.1.7 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.1.6 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.1.5 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.1.4 lib/xmlenc/algorithms/des3_cbc.rb
xmlenc-0.1.3 lib/xmlenc/algorithms/des3_cbc.rb