[][src]Struct bcrypter::Inputs

pub struct Inputs { /* fields omitted */ }

The hashing parameters, only a password is required. Defaults to a randomly generated salt and a cost of 12

Methods

impl Inputs
[src]

Checks password against a known bcrypt hash

Errors

Throws InvalidFormat when the bcrypt hash has invalid base64 or formatting

Examples

let pw = String::from("hunter2");
let hash = String::from("$2a$04$7eAf8viXin8zazyvaU2HLuZGEbvaHy/lsnlG.HFWkBST5irHhXKJO");
let correct = bcrypter::password(pw).verify(&hash);

Main hashing function. Returns a Bcrypt struct result from given inputs

Errors

Throws an InvalidCost error if the cost parameter is invalid.

Example

let pw = String::from("hunter2");
let result = bcrypter::password(pw).hash().unwrap();
let hash = result.hash_string;

Sets salt parameter for the hasher, value is ignored when calling verify function.

Example

let sixteen_bytes = [0u8; 16]; // Use appropiate random values instead
let pw = String::from("hunter2");
let result = bcrypter::password(pw).salt(sixteen_bytes).hash().unwrap();

Sets the cost parameter, value is ignored when calling verify function

Example

let pw = String::from("hunter2");
let result = bcrypter::password(pw).cost(8).hash().unwrap();

Sets any input parameter that hasn't been modified to the default values.

Auto Trait Implementations

impl Send for Inputs

impl Sync for Inputs

Blanket Implementations

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> Same for T

Should always be Self