pub struct Sha256 { /* private fields */ }Expand description
SHA-256 hash function (RFC 6234 / FIPS 180-4).
Implements the Hasher trait.
§One-shot API
ⓘ
use crypto::{Hasher, sha2::Sha256};
let hash = Sha256::hash(b"hello world");§Incremental API
ⓘ
use crypto::{Hasher, sha2::Sha256};
let mut hasher = Sha256::new();
hasher.update(b"hello ");
hasher.update(b"world");
let hash = hasher.sum();§Message length limit
FIPS 180-4 permits messages with ℓ < 2^64 bits, i.e. up to 2^61 - 1
bytes. The length is counted by a 64-bit byte counter and encoded in the
64-bit field mandated by the spec, so a message of 2^61 bytes or more produces undefined result.
Such lengths are around 2 EiB and are unreachable in
practice; they are neither rejected nor signalled, so no panic or error is
returned for them.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sha256
impl RefUnwindSafe for Sha256
impl Send for Sha256
impl Sync for Sha256
impl Unpin for Sha256
impl UnsafeUnpin for Sha256
impl UnwindSafe for Sha256
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