mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 08:25:16 +00:00
Update sha1
This commit is contained in:
@ -4,9 +4,11 @@
|
||||
|
||||
extern crate sha1;
|
||||
|
||||
use crate::data::error::{ResultBoxError, ExecError};
|
||||
use rand::{thread_rng, Rng};
|
||||
use rand::{Rng, thread_rng};
|
||||
use rand::distributions::Alphanumeric;
|
||||
use sha1::Digest;
|
||||
|
||||
use crate::data::error::{ExecError, ResultBoxError};
|
||||
|
||||
/// Generate a new sha1 string
|
||||
///
|
||||
@ -17,7 +19,10 @@ use rand::distributions::Alphanumeric;
|
||||
/// assert_eq!(res, "e5e9fa1ba31ecd1ae84f75caaa474f3a663f05f4");
|
||||
/// ```
|
||||
pub fn sha1_str(input: &str) -> String {
|
||||
sha1::Sha1::from(input).digest().to_string()
|
||||
let mut hasher = sha1::Sha1::default();
|
||||
hasher.update(input.as_bytes());
|
||||
let result = hasher.finalize();
|
||||
format!("{:x}", result)
|
||||
}
|
||||
|
||||
/// One-way user password crypt
|
||||
|
Reference in New Issue
Block a user