use glib for md5 checksums

This commit is contained in:
Erica Z 2024-11-10 15:31:32 +01:00
parent f4ba44fcb7
commit 25f082ee6f
3 changed files with 3 additions and 24 deletions

18
Cargo.lock generated
View file

@ -218,7 +218,6 @@ name = "audrey"
version = "0.1.0"
dependencies = [
"async-channel",
"base16ct",
"bindgen",
"bytes",
"chrono",
@ -228,7 +227,6 @@ dependencies = [
"glib-build-tools",
"gtk4",
"libadwaita",
"md-5",
"oo7",
"rand",
"reqwest",
@ -261,12 +259,6 @@ dependencies = [
"windows-targets",
]
[[package]]
name = "base16ct"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
[[package]]
name = "base64"
version = "0.22.1"
@ -1534,16 +1526,6 @@ checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
dependencies = [
"cfg-if",
"digest",
"md5-asm",
]
[[package]]
name = "md5-asm"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d19b8ee7fc7d812058d3b708c7f719efd0713d53854648e4223c6fcae709e2df"
dependencies = [
"cc",
]
[[package]]

View file

@ -6,14 +6,12 @@ edition = "2021"
[dependencies]
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] }
async-channel = "2.3.1"
base16ct = { version = "0.2.0", features = ["std"] }
bytes = "1.8.0"
chrono = { version = "0.4.38", features = ["serde"] }
event-listener = "5.3.1"
futures = "0.3.31"
gettext-rs = { version = "0.7.2", features = ["gettext-system"] }
gtk = { version = "0.9.2", package = "gtk4", features = ["v4_16"] }
md-5 = { version = "0.10.6", features = ["asm"] }
oo7 = "0.3.3"
rand = "0.8"
reqwest = { version = "0.12.9", default-features = false, features = [

View file

@ -3,8 +3,8 @@ pub mod schema;
mod album_list;
pub use album_list::AlbumListType;
use adw::glib;
use bytes::Bytes;
use md5::Digest;
use rand::Rng;
use tracing::{event, Level};
@ -75,11 +75,10 @@ impl Client {
// subsonic docs say to generate a salt per request, but that's completely unnecessary
let salt_hex = random_salt(SALT_BYTES);
let mut hasher = md5::Md5::new();
let mut hasher = glib::Checksum::new(glib::ChecksumType::Md5).unwrap();
hasher.update(password);
hasher.update(salt_hex.as_bytes());
let token = hasher.finalize();
let token_hex = base16ct::lower::encode_string(&token);
let token_hex = hasher.string().unwrap();
Self::with_token(url, username, &token_hex, &salt_hex)
}