Skip to content

Instantly share code, notes, and snippets.

@kenyipp
Created December 27, 2022 17:46
Show Gist options
  • Save kenyipp/4ca6d2cd083328ae6ce59687c2484d92 to your computer and use it in GitHub Desktop.
Save kenyipp/4ca6d2cd083328ae6ce59687c2484d92 to your computer and use it in GitHub Desktop.
Decoding the json web token header using the base64 and serde_json modules
#[derive(Deserialize, Debug)]
struct Header {
pub alg: String,
}
let header = base64
::decode_engine(
"JWT Header",
&FastPortable::from(&alphabet::STANDARD, fast_portable::NO_PAD)
)
.unwrap();
let decoded_json: Header = serde_json::from_slice(&header).unwrap();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment