mirror of
https://github.com/atuinsh/atuin.git
synced 2025-08-16 10:08:08 +02:00
Switch to uuid7
This commit is contained in:
2
.cargo/config.toml
Normal file
2
.cargo/config.toml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[build]
|
||||||
|
rustflags = ["--cfg", "uuid_unstable"]
|
@ -3,8 +3,19 @@ use std::path::PathBuf;
|
|||||||
use chrono::NaiveDate;
|
use chrono::NaiveDate;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
pub fn uuid_v4() -> String {
|
pub fn uuid_v7() -> String {
|
||||||
Uuid::new_v4().as_simple().to_string()
|
Uuid::now_v7().as_simple().to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn hash_str(string: &str) -> String {
|
||||||
|
hash_bytes(string.as_bytes())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn hash_bytes(buf: &[u8]) -> String {
|
||||||
|
use sha2::{Digest, Sha256};
|
||||||
|
let mut hasher = Sha256::new();
|
||||||
|
hasher.update(buf);
|
||||||
|
hex::encode(hasher.finalize())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: more reliable, more tested
|
// TODO: more reliable, more tested
|
||||||
|
Reference in New Issue
Block a user