You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
503 B
22 lines
503 B
use rand::{distributions::Alphanumeric, thread_rng, Rng}; |
|
|
|
pub struct RandomHasher { |
|
salt: String, |
|
} |
|
|
|
impl RandomHasher { |
|
pub fn get_random_one() -> RandomHasher { |
|
RandomHasher { |
|
salt: thread_rng() |
|
.sample_iter(&Alphanumeric) |
|
.take(16) |
|
.map(char::from) |
|
.collect(), |
|
} |
|
} |
|
|
|
pub fn hash_with_salt(&self, text: &str) -> String { |
|
// TODO |
|
format!("hash({}+{})", self.salt, text) |
|
} |
|
}
|
|
|