diff options
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() } |
