Struct Argon2Parameters

Source
pub struct Argon2Parameters {
    pub length: u32,
    pub lanes: u32,
    pub memory: u32,
    pub iterations: u32,
    /* private fields */
}
Expand description

Parameters used to derive the password into an Argon2 hash.

It is used to derive a password into a keypair. You should use the default, although this may be tweakable by the user in some cases. Once serialized, you can save it along the user information as it is not sensitive data. If the hash should never be computed in a non-threaded environment, you can raise the “lanes” value to enable multi-threading.

Note that calling default() will also generate a new random salt, so two calls to default() will not generate the same structure.

Fields§

§length: u32

Length of the desired hash. Should be 32 in most case.

§lanes: u32

Number of parallel jobs to run. Only use if always computed in a multithreaded environment.

§memory: u32

Memory used by the algorithm in KiB. Higher is better.

§iterations: u32

Number of iterations(time cost). Higher is better.

Implementations§

Source§

impl Argon2Parameters

Source

pub fn builder() -> Argon2ParametersBuilder<((), (), (), (), (), (), (), (), (), ())>

Create a builder for building Argon2Parameters. On the builder, call .length(...)(optional), .lanes(...)(optional), .memory(...)(optional), .iterations(...)(optional), .variant(...)(optional), .version(...)(optional), .dc_version(...)(optional), .associated_data(...)(optional), .secret_key(...)(optional), .salt(...)(optional) to set the values of the fields. Finally, call .build() to create the instance of Argon2Parameters.

Source§

impl Argon2Parameters

Source

pub fn get_salt_as_slice(&self) -> &[u8]

Source

pub fn set_salt(&mut self, salt: Vec<u8>)

Source§

impl Argon2Parameters

Source

pub fn compute(&self, password: &[u8]) -> Result<Vec<u8>>

Compute the Argon2 hash using the password and the parameters.

Trait Implementations§

Source§

impl Clone for Argon2Parameters

Source§

fn clone(&self) -> Argon2Parameters

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Argon2Parameters

Implements the default parameters.

Source§

fn default() -> Self

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

impl From<&Argon2Parameters> for Vec<u8>

Source§

fn from(params: &Argon2Parameters) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<&[u8]> for Argon2Parameters

Source§

type Error = Error

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

fn try_from(data: &[u8]) -> Result<Self>

Performs the conversion.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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