[][src]Struct lsx::sha256::BufSha256

pub struct BufSha256 { /* fields omitted */ }

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

impl Clone for BufSha256[src]

impl Copy for BufSha256[src]

impl Debug for BufSha256[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.