Created
December 27, 2022 17:46
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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