aster_forge_crypto/
lib.rs1#![deny(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
7#![cfg_attr(
8 not(test),
9 deny(
10 clippy::unwrap_used,
11 clippy::unreachable,
12 clippy::expect_used,
13 clippy::panic,
14 clippy::unimplemented,
15 clippy::todo
16 )
17)]
18
19pub mod hash;
20
21pub use hash::{
22 bytes_to_hex, hash_password, new_sha256, sha256_digest_to_hex, sha256_hex, verify_password,
23};
24
25pub type Result<T> = std::result::Result<T, CryptoError>;
27
28#[derive(Debug, thiserror::Error)]
30pub enum CryptoError {
31 #[error("password hash error: {0}")]
33 PasswordHash(String),
34}
35
36impl CryptoError {
37 pub fn password_hash(error: impl std::fmt::Display) -> Self {
39 Self::PasswordHash(error.to_string())
40 }
41}