Sha256: 7a2e0a4ad40febd68d241a9addd7923fe6807d546b78eee5bb088937d6badca3

Contents?: true

Size: 503 Bytes

Versions: 3

Compression:

Stored size: 503 Bytes

Contents

require 'jwe/enc/a128cbc_hs256'
require 'jwe/enc/a192cbc_hs384'
require 'jwe/enc/a256cbc_hs512'
require 'jwe/enc/a128gcm'
require 'jwe/enc/a192gcm'
require 'jwe/enc/a256gcm'

module JWE
  module Enc
    def self.for(enc)
      klass = enc.gsub(/[-\+]/, '_').downcase.sub(/^[a-z\d]*/) { $&.capitalize }
      klass.gsub!(/_([a-z\d]*)/i) { Regexp.last_match(1).capitalize }
      const_get(klass)

    rescue NameError
      raise NotImplementedError.new("Unsupported enc type: #{enc}")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jwe-0.3.0 lib/jwe/enc.rb
jwe-0.2.0 lib/jwe/enc.rb
jwe-0.1.1 lib/jwe/enc.rb