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 const RECOMMENDED: Self

Recommended values according to the OWASP cheat sheet.

  • log_n = 17 (n = 131072)
  • r = 8
  • p = 1
Source

pub fn new(log_n: u8, r: u32, p: u32) -> 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
§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
Source

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

Available on crate feature phc only.

Create a new instance of Params, overriding the output length.

Note that this length is only intended for use with the PasswordHasher API, and not with the low-level scrypt::scrypt API, which determines the output length using the size of the output slice.

The allowed values for len are between 10 bytes (80 bits) and 64 bytes inclusive. These lengths come from the PHC string format specification because they are intended for use with password hash strings.

Source

pub const fn recommended() -> Params

👎Deprecated since 0.12.0: use Params::RECOMMENDED instead

Deprecated: recommended values according to the OWASP cheat sheet.

Source

pub const fn log_n(&self) -> u8

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

Memory and CPU usage scale linearly with N. If you need N, use Params::n instead.

Source

pub const fn n(&self) -> u64

N parameter: the work factor.

This method returns 2 to the power of Params::log_n. Memory and CPU usage scale linearly with N.

Source

pub const fn r(&self) -> u32

r parameter: resource usage.

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

Source

pub const 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§

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

Available on crate feature phc only.
Source§

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

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

impl FromStr for Params

Available on crate feature phc only.
Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Params

Source§

fn eq(&self, other: &Params) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<&Params> for ParamsString

Available on crate feature phc 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 TryFrom<&ParamsString> for Params

Available on crate feature phc only.
Source§

type Error = Error

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

fn try_from(params: &ParamsString) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&PasswordHash> for Params

Available on crate feature phc only.
Source§

type Error = Error

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

fn try_from(hash: &PasswordHash) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Params> for ParamsString

Available on crate feature phc only.
Source§

type Error = Error

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

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

Performs the conversion.
Source§

impl Copy for Params

Source§

impl StructuralPartialEq 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§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToString for T
where T: Display + ?Sized,

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
§

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

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

Performs the conversion.