26 lines
943 B
Rust
26 lines
943 B
Rust
use crate::common::account::hash::*;
|
|
use crate::common::account::salt::*;
|
|
|
|
/// Generates a storable server email hash from a client hashed email.
|
|
///
|
|
/// Takes in a client hashed email, outputs a storable new hash. The returned result is 'safe' to
|
|
/// be stored on the server side database. The salt returned is for the hashed version of the
|
|
/// hashed client email.
|
|
///
|
|
/// Arguments:
|
|
/// hashed_email - The client hashed email sent to the server.
|
|
///
|
|
/// Returns: a tuple containing the final hash and the hash's salt, nothing on failure.
|
|
///
|
|
/// Example:
|
|
/// ```rust
|
|
/// let enc = hash_email("THISISTOTALLYAHASHEDTHING...").unwrap();
|
|
/// println!("Server Email Hash: {}", HEXUPPER.encode(&enc.0));
|
|
/// println!("Server Email Salt: {}", HEXUPPER.encode(&enc.1));
|
|
/// ```
|
|
pub fn hash_email(hashed_email: &str) -> (String, String) {
|
|
let salt = gen_salt();
|
|
let hash = hash(&hashed_email, &salt, 350_000);
|
|
(hash, salt)
|
|
}
|