Sha256: 7d8d2406da2a2211ae8c2668a92c95e97052b5175d45a4f7c878778da303485b

Contents?: true

Size: 589 Bytes

Versions: 3

Compression:

Stored size: 589 Bytes

Contents

# frozen_string_literal: true

module Xml
  module Kit
    module Crypto
      class RsaCipher
        ALGORITHM = "#{::Xml::Kit::Namespaces::XMLENC}rsa-1_5"
        attr_reader :algorithm, :key

        def initialize(algorithm, key)
          @algorithm = algorithm
          @key = key
        end

        def self.matches?(algorithm)
          ALGORITHM == algorithm
        end

        def encrypt(plain_text)
          @key.public_encrypt(plain_text)
        end

        def decrypt(cipher_text)
          @key.private_decrypt(cipher_text)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xml-kit-0.6.0 lib/xml/kit/crypto/rsa_cipher.rb
xml-kit-0.5.0 lib/xml/kit/crypto/rsa_cipher.rb
xml-kit-0.4.0 lib/xml/kit/crypto/rsa_cipher.rb