pub struct ScryptHasher {
pub params: ScryptParams,
}Expand description
A scrypt password hasher that bundles its own cost parameters.
Implements PasswordHash so it can be
used polymorphically with crate::verify_password.
§Design note — params argument is ignored
The PasswordHash::hash_password
trait method accepts a params: &dyn PasswordHashParams argument, but this
implementation ignores it and uses self.params instead. Callers that
need different scrypt parameters should construct a new ScryptHasher
with the desired ScryptParams rather than passing a different
PasswordHashParams object.
Fields§
§params: ScryptParamsScrypt cost parameters.
Implementations§
Source§impl ScryptHasher
impl ScryptHasher
Sourcepub fn new(params: ScryptParams) -> Result<Self, CryptoError>
pub fn new(params: ScryptParams) -> Result<Self, CryptoError>
Create a new hasher with explicit parameters.
Returns an error if the parameters are out of range.
Sourcepub fn new_checked(params: ScryptParams) -> Self
pub fn new_checked(params: ScryptParams) -> Self
Create a new hasher, panicking if params are invalid.
Prefer ScryptHasher::new in production code.
Sourcepub fn interactive() -> Self
pub fn interactive() -> Self
Interactive login preset.
Trait Implementations§
Source§impl Clone for ScryptHasher
impl Clone for ScryptHasher
Source§fn clone(&self) -> ScryptHasher
fn clone(&self) -> ScryptHasher
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ScryptHasher
impl Debug for ScryptHasher
Source§impl PasswordHash for ScryptHasher
impl PasswordHash for ScryptHasher
Source§fn hash_password(
&self,
password: &[u8],
salt: &[u8],
_params: &dyn PasswordHashParams,
out: &mut [u8],
) -> Result<(), CryptoError>
fn hash_password( &self, password: &[u8], salt: &[u8], _params: &dyn PasswordHashParams, out: &mut [u8], ) -> Result<(), CryptoError>
Hash
password with salt using the given params; write output into out.impl Copy for ScryptHasher
Auto Trait Implementations§
impl Freeze for ScryptHasher
impl RefUnwindSafe for ScryptHasher
impl Send for ScryptHasher
impl Sync for ScryptHasher
impl Unpin for ScryptHasher
impl UnsafeUnpin for ScryptHasher
impl UnwindSafe for ScryptHasher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more