Params

Struct 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 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 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.
Source§

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.
Source§

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§

§

impl Freeze for Params

§

impl RefUnwindSafe for Params

§

impl Send for Params

§

impl Sync for Params

§

impl Unpin for Params

§

impl UnwindSafe for Params

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.