hash: secret: defaults at 64, can generate custom length

This commit is contained in:
Philippe Loctaux 2023-03-16 22:29:51 +01:00
parent 64f3db3864
commit 0866de94b6

View file

@ -5,10 +5,14 @@ use nanoid_dictionary::ALPHANUMERIC;
// Struct to generate the secret
pub struct SecretString(String);
const LENGTH: usize = 64;
impl SecretString {
pub fn new(length: usize) -> Self {
Self(nanoid!(length, ALPHANUMERIC))
}
}
impl Default for SecretString {
fn default() -> Self {
Self(nanoid!(LENGTH, ALPHANUMERIC))
Self::new(64)
}
}