[][src]Struct lsx::sha256::RawSha256

pub struct RawSha256 { /* fields omitted */ }

A raw SHA-256 state. This does not include a buffer, so you must provide data in exact increments of BLOCKBYTES (64 bytes).

const DATA: &[u8] = b"Lorem ipsum dolor sit amet, consectetur adipisicing \
                      elit, sed do eiusmod tempor incididunt ut labore et \
                      dolore magna aliqua. Ut enim ad minim veniam, quis \
                      nostrud exercitation ullamco laboris nisi ut \
                      aliquip ex ea commodo consequat. Duis aute irure \
                      dolor in reprehenderit in voluptate velit esse \
                      cillum dolore eu fugiat nulla pariatur. Excepteur \
                      sint occaecat cupidatat non proident, sunt in culpa \
                      qui officia deserunt mollit anim id est laborum.";
let mut hasher = RawSha256::new();
hasher.update(&DATA[.. sha256::BLOCKBYTES]);
// you can provide more than one block (this next call provides two)
hasher.update(&DATA[sha256::BLOCKBYTES .. sha256::BLOCKBYTES * 3]);
// empty blocks have no effect
hasher.update(&[]);
// finish can handle more than one block if needed
assert_eq!(hasher.finish(&DATA[sha256::BLOCKBYTES * 3 ..]),
           [0x2c,0x7c,0x3d,0x5f,0x24,0x4f,0x1a,0x40,0x06,0x9a,0x32,0x22,
            0x42,0x15,0xe0,0xcf,0x9b,0x42,0x48,0x5c,0x99,0xd8,0x0f,0x35,
            0x7d,0x76,0xf0,0x06,0x35,0x9c,0x7a,0x18]);

Implementations

impl RawSha256[src]

pub fn new() -> RawSha256[src]

Start a new hash.

pub fn update(&mut self, data: &[u8])[src]

Process some blocks of data. Panics if the input is not an exact multiple of BLOCKBYTES (64 bytes).

pub fn finish(self, data: &[u8]) -> [u8; 32][src]

Process the remaining data and produce a finished hash. The input does not need to be a multiple of BLOCKBYTES.

Trait Implementations

impl Clone for RawSha256[src]

impl Copy for RawSha256[src]

impl Debug for RawSha256[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.