From b9e553f1127f33d8caf7e2dd1281e3c589300426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Thu, 3 Jul 2025 14:20:30 +0000 Subject: [PATCH] use `base64` crate instead of `base64ct`, no constant time necessary --- Cargo.lock | 8 +------- Cargo.toml | 2 +- src/cli.rs | 4 ++-- src/file/mod.rs | 4 ++-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cb94d7e..3d39562 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,12 +85,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "base64ct" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" - [[package]] name = "bitflags" version = "2.9.1" @@ -881,7 +875,7 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" name = "shrupl" version = "0.1.0-alpha" dependencies = [ - "base64ct", + "base64", "blake2b_simd", "clap", "console", diff --git a/Cargo.toml b/Cargo.toml index 9b87ac4..18b12cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2024" description = "ShrUpl is a tool to upload files to a Sharry Instance through a public Alias, leveraging the tus protocol" [dependencies] -base64ct = { version = "1.8.0", default-features = false, features = ["alloc"] } +base64 = { version = "0.22.1", default-features = false } blake2b_simd = "1.0.3" clap = { version = "4.5.38", features = ["derive"] } console = { version = "0.15.11", default-features = false } diff --git a/src/cli.rs b/src/cli.rs index abc0237..223b698 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,6 +1,6 @@ use std::{convert::Infallible, fmt, io, time::Duration}; -use base64ct::{Base64UrlUnpadded, Encoding}; +use base64::{Engine, prelude::BASE64_URL_SAFE_NO_PAD as BASE64URL}; use blake2b_simd::Params as Blake2b; use clap::{Parser, builder::TypedValueParser, value_parser}; use log::LevelFilter; @@ -153,6 +153,6 @@ impl Cli { hasher.update(chk.as_ref()); } - Base64UrlUnpadded::encode_string(hasher.finalize().as_bytes()) + BASE64URL.encode(hasher.finalize()) } } diff --git a/src/file/mod.rs b/src/file/mod.rs index 07a0026..e7ec53a 100644 --- a/src/file/mod.rs +++ b/src/file/mod.rs @@ -4,7 +4,7 @@ mod uploading; use std::{ffi::OsStr, fs, io::Read, path::Path}; -use base64ct::{Base64, Encoding}; +use base64::{Engine, prelude::BASE64_STANDARD_NO_PAD as BASE64}; use blake2b_simd::Params as Blake2b; pub use checked::Checked; @@ -35,7 +35,7 @@ fn compute_file_hash(path: &Path, size: u64, on_progress: impl Fn(u64)) -> crate return Err(crate::Error::mismatch(size, bytes_read)); } - let result = Base64::encode_string(hasher.finalize().as_bytes()); + let result = BASE64.encode(hasher.finalize()); debug!("hashed {:?}: {result:?}", path.display()); Ok(result) }