Sha256: 163524353ffac8301fd1345aea0c2eac10adce7fdec6082e813893c8a3107136

Contents?: true

Size: 506 Bytes

Versions: 3

Compression:

Stored size: 506 Bytes

Contents

module JWE
  module Serialization
    class Compact
      def self.encode(header, encrypted_cek, iv, ciphertext, tag)
        [header, encrypted_cek, iv, ciphertext, tag].map { |piece| JWE::Base64.jwe_encode(piece) }.join '.'
      end

      def self.decode(payload)
        parts = payload.split('.')
        raise JWE::DecodeError.new('Not enaugh or too many segments') unless parts.length == 5

        parts.map do |part|
          JWE::Base64.jwe_decode(part)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jwe-0.3.0 lib/jwe/serialization/compact.rb
jwe-0.2.0 lib/jwe/serialization/compact.rb
jwe-0.1.1 lib/jwe/serialization/compact.rb