add: icon resolver
add: config "no_track" file list option add: rainbeam-shared -> tetratto-shared add: l10n
This commit is contained in:
parent
b6fe2fba37
commit
d2ca9e23d3
40 changed files with 1107 additions and 583 deletions
38
crates/shared/src/hash.rs
Normal file
38
crates/shared/src/hash.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
use hex_fmt::HexFmt;
|
||||
use rand::{Rng, distr::Alphanumeric, rng};
|
||||
use sha2::{Digest, Sha256};
|
||||
use uuid::Uuid;
|
||||
|
||||
// ids
|
||||
pub fn uuid() -> String {
|
||||
let uuid = Uuid::new_v4();
|
||||
uuid.to_string()
|
||||
}
|
||||
|
||||
pub fn hash(input: String) -> String {
|
||||
let mut hasher = <Sha256 as Digest>::new();
|
||||
hasher.update(input.into_bytes());
|
||||
|
||||
let res = hasher.finalize();
|
||||
HexFmt(res).to_string()
|
||||
}
|
||||
|
||||
pub fn hash_salted(input: String, salt: String) -> String {
|
||||
let mut hasher = <Sha256 as Digest>::new();
|
||||
hasher.update(format!("{salt}{input}").into_bytes());
|
||||
|
||||
let res = hasher.finalize();
|
||||
HexFmt(res).to_string()
|
||||
}
|
||||
|
||||
pub fn salt() -> String {
|
||||
rng()
|
||||
.sample_iter(&Alphanumeric)
|
||||
.take(16)
|
||||
.map(char::from)
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn random_id() -> String {
|
||||
hash(uuid())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue