[−][src]Struct bcrypter::Inputs
The hashing parameters, only a password is required. Defaults to a randomly generated salt and a cost of 12
Methods
impl Inputs
[src]
impl Inputs
pub fn verify(self, bcrypt_hash: &str) -> Result<bool, InvalidFormat>
[src]
pub fn verify(self, bcrypt_hash: &str) -> Result<bool, InvalidFormat>
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);
pub fn hash(self) -> Result<Bcrypt, InvalidCost>
[src]
pub fn hash(self) -> Result<Bcrypt, InvalidCost>
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;
pub fn salt(self, salt: [u8; 16]) -> Inputs
[src]
pub fn salt(self, salt: [u8; 16]) -> Inputs
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();
pub fn cost(self, cost: u8) -> Inputs
[src]
pub fn cost(self, cost: u8) -> Inputs
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();
pub fn set_defualts(self) -> Inputs
[src]
pub fn set_defualts(self) -> Inputs
Sets any input parameter that hasn't been modified to the default values.
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 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
impl<T> Same for T
type Output = T
Should always be Self