hash: secret: defaults at 64, can generate custom length
This commit is contained in:
parent
64f3db3864
commit
0866de94b6
1 changed files with 6 additions and 2 deletions
|
|
@ -5,10 +5,14 @@ use nanoid_dictionary::ALPHANUMERIC;
|
||||||
|
|
||||||
// Struct to generate the secret
|
// Struct to generate the secret
|
||||||
pub struct SecretString(String);
|
pub struct SecretString(String);
|
||||||
const LENGTH: usize = 64;
|
impl SecretString {
|
||||||
|
pub fn new(length: usize) -> Self {
|
||||||
|
Self(nanoid!(length, ALPHANUMERIC))
|
||||||
|
}
|
||||||
|
}
|
||||||
impl Default for SecretString {
|
impl Default for SecretString {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self(nanoid!(LENGTH, ALPHANUMERIC))
|
Self::new(64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue