Struct argon2::Config

source ·
pub struct Config<'a> {
    pub ad: &'a [u8],
    pub hash_length: u32,
    pub lanes: u32,
    pub mem_cost: u32,
    pub secret: &'a [u8],
    pub time_cost: u32,
    pub variant: Variant,
    pub version: Version,
}
Expand description

Structure containing configuration settings.

Examples

use argon2::{Config, Variant, Version};

let config = Config::default();
assert_eq!(config.ad, &[]);
assert_eq!(config.hash_length, 32);
assert_eq!(config.lanes, 1);
assert_eq!(config.mem_cost, 19 * 1024);
assert_eq!(config.secret, &[]);
assert_eq!(config.time_cost, 2);
assert_eq!(config.variant, Variant::Argon2id);
assert_eq!(config.version, Version::Version13);

Fields§

§ad: &'a [u8]

The associated data.

§hash_length: u32

The length of the resulting hash.

§lanes: u32

The number of lanes.

§mem_cost: u32

The amount of memory requested (KB).

§secret: &'a [u8]

The key.

§time_cost: u32

The number of passes.

§variant: Variant

The variant.

§version: Version

The version number.

Implementations§

source§

impl<'a> Config<'a>

source

pub fn original() -> Config<'a>

Default configuration used by the original C implementation.

source

pub fn owasp1() -> Config<'a>

OWASP recommended configuration with t=1 and 46 MiB memory.

source

pub fn owasp2() -> Config<'a>

OWASP recommended configuration with t=2 and 19 MiB memory.

source

pub fn owasp3() -> Config<'a>

OWASP recommended configuration with t=3 and 12 MiB memory.

source

pub fn owasp4() -> Config<'a>

OWASP recommended configuration with t=4 and 9 MiB memory.

source

pub fn owasp5() -> Config<'a>

OWASP recommended configuration with t=5 and 7 MiB memory.

source

pub fn rfc9106() -> Config<'a>

RFC9106 recommended configuration with t=1 and 2 GiB memory.

source

pub fn rfc9106_low_mem() -> Config<'a>

RFC9106 recommended configuration for memory-constrained environments.

Trait Implementations§

source§

impl<'a> Clone for Config<'a>

source§

fn clone(&self) -> Config<'a>

Returns a copy 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<'a> Debug for Config<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Default for Config<'a>

source§

fn default() -> Config<'a>

OWASP recommended configuration with t=2 and 19 MiB memory.

source§

impl<'a> PartialEq for Config<'a>

source§

fn eq(&self, other: &Config<'a>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> StructuralPartialEq for Config<'a>

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Config<'a>

§

impl<'a> Send for Config<'a>

§

impl<'a> Sync for Config<'a>

§

impl<'a> Unpin for Config<'a>

§

impl<'a> UnwindSafe for Config<'a>

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

§

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>,

§

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>,

§

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.