diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-06-12 01:54:21 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-06-12 01:54:21 +0200 |
| commit | bbdf38018b47328b5faa2cef635c37095045be72 (patch) | |
| tree | 8983817d547551ae12508a8ae8731b622d990af4 /crates/turtle/src/atuin_common/utils.rs | |
| parent | feat(server): Make user stuff stateless (diff) | |
| download | atuin-bbdf38018b47328b5faa2cef635c37095045be72.zip | |
feat(server): Really make users stateless (with tests)
This commit also remove another load of unneeded features.
Diffstat (limited to 'crates/turtle/src/atuin_common/utils.rs')
| -rw-r--r-- | crates/turtle/src/atuin_common/utils.rs | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/crates/turtle/src/atuin_common/utils.rs b/crates/turtle/src/atuin_common/utils.rs index 09718241..ba0c8eb7 100644 --- a/crates/turtle/src/atuin_common/utils.rs +++ b/crates/turtle/src/atuin_common/utils.rs @@ -2,30 +2,8 @@ use std::borrow::Cow; use std::env; use std::path::{Path, PathBuf}; -use base64::prelude::{BASE64_URL_SAFE_NO_PAD, Engine}; -use getrandom::getrandom; use uuid::Uuid; -/// Generate N random bytes, using a cryptographically secure source -pub(crate) fn crypto_random_bytes<const N: usize>() -> [u8; N] { - // rand say they are in principle safe for crypto purposes, but that it is perhaps a better - // idea to use getrandom for things such as passwords. - let mut ret = [0u8; N]; - - getrandom(&mut ret).expect("Failed to generate random bytes!"); - - ret -} - -/// Generate N random bytes using a cryptographically secure source, return encoded as a string -pub(crate) fn crypto_random_string<const N: usize>() -> String { - let bytes = crypto_random_bytes::<N>(); - - // We only use this to create a random string, and won't be reversing it to find the original - // data - no padding is OK there. It may be in URLs. - BASE64_URL_SAFE_NO_PAD.encode(bytes) -} - pub(crate) fn uuid_v7() -> Uuid { Uuid::now_v7() } |
