Last active
October 2, 2024 13:44
-
-
Save kennwhite/4c6d4bea72ccf10826ef3d4cdfa947ca to your computer and use it in GitHub Desktop.
Rust and base64 encoding decode madness
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
// YOU HAVE LOTS OF...OPTIONS WITH RUST'S BASE64 ECOSYSTEM. base64::decode() was deprecated Jan 2023 | |
// | |
// use base64; // let key = base64::decode(base64_key); // <=== classic method, but will throw Deprecation warnings | |
// use base64::prelude::*; // let key = BASE64_STANDARD.decode(base64_key)?; | |
// use data_encoding::BASE64; // let key = BASE64.decode( b"SGVsbA...gh=" ) // b prefix is required | |
// use base64::{Engine as _, alphabet, engine::{self, general_purpose}}; // let key = general_purpose::STANDARD.decode(...); | |
// use base64::{Engine as _, engine::{general_purpose}}; // let key = general_purpose::STANDARD.decode(...); | |
// use base64::{Engine as _, engine::general_purpose}; // let key = general_purpose::STANDARD.decode(...); | |
// use base64::{Engine as _, engine::{general_purpose::STANDARD as base64}}; // let key = base64.decode(...); // DANGER!! | |
// use base64::{Engine as _, engine::{general_purpose as BASE64}}; // let key = BASE64::STANDARD.decode(...); | |
// use base64::{Engine as _, engine::{general_purpose::STANDARD as BASE64}}; // let key = BASE64.decode(...); | |
//use base64::{Engine as _, engine::{general_purpose as BASE64}}; // let key = BASE64::STANDARD.decode(...).unwrap(); | |
use base64::{Engine as _, engine::{general_purpose as BASE64}}; | |
... | |
let base64_key = "Mng0NCt4ZHVUYUJCa1k....xNk"; | |
let key = BASE64::STANDARD.decode(base64_key).unwrap(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my compiler warns me about "unnecessary braces", so I have: