[−][src]Struct lsx::sha256::BufSha256
A SHA-256 state, including a buffer to allow non-block-sized inputs.
const DATA_1: &[u8] = b"Here is a piece of text that is not exactly 64 \ characters."; const DATA_2: &[u8] = b"Here is another piece of text that's not \ contiguous in memory with the other one."; const DATA_3: &[u8] = b"Have a little more text!"; let mut hasher = BufSha256::new(); hasher.update(DATA_1); hasher.update(DATA_2); let hash1 = hasher.finish(DATA_3); assert_eq!(hash1, [0xa7,0x15,0xf7,0x84,0xb9,0xb3,0xd7,0x45,0x15,0x9f,0xe7,0x5f, 0xfa,0xab,0xaa,0xf9,0xf3,0x9c,0xa6,0x44,0x29,0xa6,0xd6,0x34, 0x86,0x66,0x2a,0x1f,0x0b,0xce,0xbd,0xdb]); // You can also provide an empty slice when finishing let mut hasher = BufSha256::new(); hasher.update(DATA_1); hasher.update(DATA_2); hasher.update(DATA_3); let hash2 = hasher.finish(&[]); assert_eq!(hash1, hash2);
Implementations
impl BufSha256
[src]
pub fn new() -> BufSha256
[src]
Initialize a SHA-256 state.
pub fn update(&mut self, data: &[u8])
[src]
Process some data. You may provide any amount of data you wish.
pub fn finish(self, data: &[u8]) -> [u8; 32]
[src]
Process any remaining data and produce a finished hash.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for BufSha256
impl Send for BufSha256
impl Sync for BufSha256
impl Unpin for BufSha256
impl UnwindSafe for BufSha256
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,