Struct scrypt::Params

source ·
pub struct Params { /* private fields */ }
Expand description

The Scrypt parameter values.

Implementations§

source§

impl Params

source

pub const RECOMMENDED_LOG_N: u8 = 17u8

Recommended log₂ of the Scrypt parameter N: CPU/memory cost.

source

pub const RECOMMENDED_R: u32 = 8u32

Recommended Scrypt parameter r: block size.

source

pub const RECOMMENDED_P: u32 = 1u32

Recommended Scrypt parameter p: parallelism.

source

pub const RECOMMENDED_LEN: usize = 32usize

Recommended Scrypt parameter Key length.

source

pub fn new(log_n: u8, r: u32, p: u32, len: usize) -> Result<Params, InvalidParams>

Create a new instance of Params.

Arguments
  • log_n - The log₂ of the Scrypt parameter N
  • r - The Scrypt parameter r
  • p - The Scrypt parameter p
  • len - The Scrypt parameter Key length
Conditions
  • log_n must be less than 64
  • r must be greater than 0 and less than or equal to 4294967295
  • p must be greater than 0 and less than 4294967295
  • len must be greater than 9 and less than or equal to 64
source

pub fn recommended() -> Params

Recommended values sufficient for most use-cases

  • log_n = 15 (n = 32768)
  • r = 8
  • p = 1
source

pub fn log_n(&self) -> u8

log₂ of the Scrypt parameter N, the work factor.

Memory and CPU usage scale linearly with N.

source

pub fn r(&self) -> u32

r parameter: resource usage.

scrypt iterates 2*r times. Memory and CPU time scale linearly with this parameter.

source

pub fn p(&self) -> u32

p parameter: parallelization.

Trait Implementations§

source§

impl Clone for Params

source§

fn clone(&self) -> Params

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 Debug for Params

source§

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

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

impl Default for Params

source§

fn default() -> Params

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

impl<'a> TryFrom<&'a PasswordHash<'a>> for Params

Available on crate feature simple only.
§

type Error = Error

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

fn try_from(hash: &'a PasswordHash<'a>) -> Result<Self, Error>

Performs the conversion.
source§

impl TryFrom<Params> for ParamsString

Available on crate feature simple only.
§

type Error = Error

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

fn try_from(input: Params) -> Result<ParamsString, Error>

Performs the conversion.
source§

impl Copy for Params

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.