Encode key in base64 instead of hexa

This commit is contained in:
ManyTheFish 2022-06-01 15:50:13 +02:00
parent 94b32cce01
commit 7652295d2c
3 changed files with 3 additions and 1 deletions

1
Cargo.lock generated
View File

@ -1973,6 +1973,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
name = "meilisearch-auth"
version = "0.27.1"
dependencies = [
"base64",
"enum-iterator",
"meilisearch-error",
"milli",

View File

@ -11,6 +11,7 @@ rand = "0.8.4"
serde = { version = "1.0.136", features = ["derive"] }
serde_json = { version = "1.0.79", features = ["preserve_order"] }
sha2 = "0.10.2"
base64 = "0.13.0"
thiserror = "1.0.30"
time = { version = "0.3.7", features = ["serde-well-known", "formatting", "parsing", "macros"] }
uuid = { version = "0.8.2", features = ["serde", "v4"] }

View File

@ -238,7 +238,7 @@ impl<'a> milli::heed::BytesEncode<'a> for KeyIdActionCodec {
pub fn generate_key(uid: &[u8], master_key: &[u8]) -> String {
let key = [uid, master_key].concat();
let sha = Sha256::digest(&key);
format!("{:x}", sha)
base64::encode_config(sha, base64::URL_SAFE_NO_PAD)
}
/// Divides one slice into two at an index, returns `None` if mid is out of bounds.