Module: JsonWebToken::Jwa
- Defined in:
- lib/json_web_token/jwa.rb
Constant Summary collapse
- ALGORITHMS =
/(HS|RS)(256|384|512)?/i- ALG_LENGTH =
5
Class Method Summary collapse
- .signed(algorithm, key, data) ⇒ Object
- .validated_constant(str) ⇒ Object
- .verified?(signature, algorithm, key, data) ⇒ Boolean
Class Method Details
.signed(algorithm, key, data) ⇒ Object
12 13 14 15 |
# File 'lib/json_web_token/jwa.rb', line 12 def signed(algorithm, key, data) alg = validated_alg(algorithm) alg[:constant].signed(alg[:sha_bits], key, data) end |
.validated_constant(str) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/json_web_token/jwa.rb', line 38 def validated_constant(str) case str when 'hs' then Algorithm::Hmac when 'rs' then Algorithm::Rsa else fail('Unsupported algorithm') end end |
.verified?(signature, algorithm, key, data) ⇒ Boolean
17 18 19 20 |
# File 'lib/json_web_token/jwa.rb', line 17 def verified?(signature, algorithm, key, data) alg = validated_alg(algorithm) alg[:constant].verified?(signature, alg[:sha_bits], key, data) end |