yajwt v1.0.1 JWT.Jwa
Choose a cryptographic algorithm to be used for a JSON Web Signature (JWS)
see http://tools.ietf.org/html/rfc7518
Summary
Functions
Return a tuple with a valid encryption module and sha_bits; raise if string
is not a supported algorithm
Return a Message Authentication Code (MAC) for a particular algorithm
Predicate to validate that mac
does verify by algorithm
Functions
Return a tuple with a valid encryption module and sha_bits; raise if string
is not a supported algorithm
Example
iex> JWT.Jwa.destructured_alg("HS256")
{JWT.Algorithm.Hmac, :sha256}
Return a Message Authentication Code (MAC) for a particular algorithm
Example
iex> key = "gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C"
...> JWT.Jwa.sign("HS256", key, "signing_input")
<<90, 34, 44, 252, 147, 130, 167, 173, 86, 191, 247, 93, 94, 12, 200, 30, 173, 115, 248, 89, 246, 222, 4, 213, 119, 74, 70, 20, 231, 194, 104, 103>>
Predicate to validate that mac
does verify by algorithm
Example
iex> mac = <<90, 34, 44, 252, 147, 130, 167, 173, 86, 191, 247, 93, 94, 12, 200, 30, 173, 115, 248, 89, 246, 222, 4, 213, 119, 74, 70, 20, 231, 194, 104, 103>>
...> key = "gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C"
...> JWT.Jwa.verify?(mac, "HS256", key, "signing_input")
true