Argon2Impl

Struct Argon2Impl 

Source
pub struct Argon2Impl {
    pub params: Params,
}
Expand description

Argon2 算法实现 Argon2 是一种内存硬化的密码哈希函数,被选为 Password Hashing Competition 的获胜者

Fields§

§params: Params

Argon2 算法参数

Trait Implementations§

Source§

impl Default for Argon2Impl

为 Argon2Impl 实现默认构造函数

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PasswordHasherImpl for Argon2Impl

为 Argon2Impl 实现 PasswordHasherImpl trait

Source§

fn hash_password(&self, password: &str) -> Result<String, PasswordError>

使用 Argon2 算法对密码进行哈希处理 会自动生成随机salt 不需要手动指定 更加安全

§参数
  • password - 需要哈希的原始密码
§返回值

返回哈希后的字符串结果或错误信息

Source§

fn verify_password( &self, password: &str, hashed: &str, ) -> Result<bool, PasswordError>

验证密码与哈希值是否匹配

§参数
  • password - 待验证的原始密码
  • hashed - 已存储的哈希值
§返回值

返回布尔值表示密码是否匹配,或者返回错误信息

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V