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

Function decode_header

src/decoding.rs:318–323  ·  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

316/// let header = decode_header(&token);
317/// ```
318pub fn decode_header(token: impl AsRef<[u8]>) -> Result<Header> {
319 let token = token.as_ref();
320 let (_, message) = expect_two!(token.rsplitn(2, |b| *b == b'.'));
321 let (_, header) = expect_two!(message.rsplitn(2, |b| *b == b'.'));
322 Header::from_encoded(header)
323}
324
325pub(crate) fn verify_signature_body(
326 message: &[u8],

Callers 3

decodeFunction · 0.85
decode_header_onlyFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected