pub struct Hash {
pub work_factor: WorkFactor,
pub salt: Salt,
pub hash: [u8; 23],
}
Expand description
A bcrypt hash, comprising a work factor, salt, and digest bytes. Holds information equivalent to the $2b$…
format created by OpenBSD’s bcrypt.
Fields§
§work_factor: WorkFactor
The hash’s work factor.
salt: Salt
The hash’s salt.
hash: [u8; 23]
The actual output of the hash.
Implementations§
Source§impl Hash
impl Hash
Sourcepub fn to_formatted(&self) -> [u8; 60]
pub fn to_formatted(&self) -> [u8; 60]
Converts the hash to $2b$…
form as exactly 60 ASCII bytes.
let hash = Hash {
work_factor: WorkFactor::EXP4,
salt: Salt::from_bytes(&[b'*'; 16]),
hash: *b"\xa2\x16\x9di\xe4\x9c\xaa\xf5\xe6]0>\x81=_\\,N\xab\x0c\x00\xd3)",
};
assert_eq!(
str::from_utf8(&hash.to_formatted()).unwrap(),
"$2b$04$IgmoIgmoIgmoIgmoIgmoIemfYbYcQaotVkVR.8eRzdVAvMouu.ywi"
);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Hash
impl RefUnwindSafe for Hash
impl Send for Hash
impl Sync for Hash
impl Unpin for Hash
impl UnwindSafe for Hash
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more