Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump base64 from 0.20.0 to 0.21.0 #182

Merged
merged 8 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bench = false
clap = {version = "4.1.4", features = ["derive"]}
log = "0.4"
env_logger = "0.10.0"
base64 = "0.20.0"
base64 = "0.21.0"
rayon = "1.6.1"
lemmeknow = "0.7.0"
include_dir = "0.7.3"
Expand Down
6 changes: 5 additions & 1 deletion src/decoders/base64_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
///
use crate::checkers::CheckerTypes;
use crate::decoders::interface::check_string_success;
use base64::{engine::general_purpose, Engine as _};

use super::crack_results::CrackResult;
use super::interface::Crack;
Expand Down Expand Up @@ -85,9 +86,12 @@ impl Crack for Decoder<Base64Decoder> {

/// helper function
fn decode_base64_no_error_handling(text: &str) -> Option<String> {
// Strip all padding
let text = text.replace('=', "");
// Runs the code to decode base64
// Doesn't perform error handling, call from_base64
base64::decode(text.as_bytes())
general_purpose::STANDARD_NO_PAD
.decode(text.as_bytes())
.ok()
.map(|inner| String::from_utf8(inner).ok())?
}
Expand Down
16 changes: 7 additions & 9 deletions src/decoders/base64_url_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
///
use crate::checkers::CheckerTypes;
use crate::decoders::interface::check_string_success;
use base64::{engine::general_purpose, Engine as _};

use super::crack_results::CrackResult;
use super::interface::Crack;
Expand Down Expand Up @@ -85,17 +86,14 @@ impl Crack for Decoder<Base64URLDecoder> {

/// helper function
fn decode_base64_url_no_error_handling(text: &str) -> Option<String> {
// Strip all padding
let text = text.replace('=', "");
// Runs the code to decode base64_url
// Doesn't perform error handling, call from_base64_url
base64::decode_engine(
text.as_bytes(),
&base64::engine::fast_portable::FastPortable::from(
&base64::alphabet::URL_SAFE,
base64::engine::fast_portable::PAD,
),
)
.ok()
.map(|inner| String::from_utf8(inner).ok())?
general_purpose::URL_SAFE_NO_PAD
.decode(text.as_bytes())
.ok()
.map(|inner| String::from_utf8(inner).ok())?
}

#[cfg(test)]
Expand Down