Struct Scrypt

Source
pub struct Scrypt { /* private fields */ }
Expand description

Main scrypt structure.

Usage:

extern crate dumb_crypto;

use::dumb_crypto::scrypt::Scrypt;

let scrypt = Scrypt::new(1, 128, 1);

let mut out: [u8; 8] = [0; 8];

scrypt.derive(b"passphrase", b"salt", &mut out).unwrap();

assert_eq!(out.to_vec(), vec![
    79, 35, 225, 99, 145, 145, 172, 245,
]);

Implementations§

Source§

impl Scrypt

Source

pub fn new(r: usize, n: usize, p: usize) -> Self

Create new instance of Scrypt.

Arguments:

  • r Block size parameter, must be larger than 1
  • n CPU/Memory cost parameter, must be larger than 1, a power of 2 and less than 2 ^ (16 * r)
  • p Parallelization parameter, a positive integer less than or equal to (2^32-1) / (4 * r) where hLen is 32 and MFlen is 128 * r.
Source

pub fn derive( self: &Scrypt, passphrase: &[u8], salt: &[u8], out: &mut [u8], ) -> Result<(), ScryptError>

Derive secret string using passphrase and salt.

Auto Trait Implementations§

§

impl Freeze for Scrypt

§

impl RefUnwindSafe for Scrypt

§

impl Send for Scrypt

§

impl Sync for Scrypt

§

impl Unpin for Scrypt

§

impl UnwindSafe for Scrypt

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