MCPcopy Create free account
hub / github.com/Keats/jsonwebtoken / decode_header

Function decode_header

src/decoding.rs:343–348  ·  view source on GitHub ↗

Decode a JWT without any signature verification/validations and return its [Header](struct.Header.html). If the token has an invalid format (ie 3 parts separated by a `.`), it will return an error. ```rust use jsonwebtoken::decode_header; let token = "a.jwt.token".to_string(); let header = decode_header(&token); ```

(token: impl AsRef<[u8]>)

Source from the content-addressed store, hash-verified

341/// let header = decode_header(&token);
342/// ```
343pub fn decode_header(token: impl AsRef<[u8]>) -> Result<Header> {
344 let token = token.as_ref();
345 let (_, message) = expect_two!(token.rsplitn(2, |b| *b == b'.'));
346 let (_, header) = expect_two!(message.rsplitn(2, |b| *b == b'.'));
347 Header::from_encoded_unchecked(header)
348}
349
350pub(crate) fn verify_signature_body(
351 message: &[u8],

Callers 2

decode_header_onlyFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected