jwt_encode_hmac {jose} | R Documentation |
Sign or verify a JSON web token. The jwt_encode_hmac
, jwt_encode_rsa
,
and jwt_encode_ec
default to HS256
, RS256
, and ES256
respectively. See jwt.io or
RFC7519 for more details.
jwt_encode_hmac(claim = jwt_claim(), secret, size = 256, header = NULL) jwt_decode_hmac(jwt, secret) jwt_encode_sig(claim = jwt_claim(), key, size = 256, header = NULL) jwt_decode_sig(jwt, pubkey) jwt_split(jwt)
claim |
a named list with fields to include in the jwt payload |
secret |
string or raw vector with a secret passphrase |
size |
bitsize of sha2 signature, i.e. |
header |
named list with additional parameter fields to include in the jwt header as defined in rfc7515 section 9.1.2 |
jwt |
string containing the JSON Web Token (JWT) |
key |
path or object with RSA or EC private key, see openssl::read_key. |
pubkey |
path or object with RSA or EC public key, see openssl::read_pubkey. |
# HMAC signing mysecret <- "This is super secret" token <- jwt_claim(name = "jeroen", session = 123456) sig <- jwt_encode_hmac(token, mysecret) jwt_decode_hmac(sig, mysecret) # RSA encoding mykey <- openssl::rsa_keygen() pubkey <- as.list(mykey)$pubkey sig <- jwt_encode_sig(token, mykey) jwt_decode_sig(sig, pubkey) # Same with EC mykey <- openssl::ec_keygen() pubkey <- as.list(mykey)$pubkey sig <- jwt_encode_sig(token, mykey) jwt_decode_sig(sig, pubkey) # Get elements of the key mysecret <- "This is super secret" token <- jwt_claim(name = "jeroen", session = 123456) jwt <- jwt_encode_hmac(token, mysecret) jwt_split(jwt)