Struct SHA256

Source
pub struct SHA256 { /* private fields */ }
Expand description

Main digest structure.

Usage:

extern crate dumb_crypto;

use::dumb_crypto::sha256::SHA256;

let mut sha256 = SHA256::new();

sha256.update(b"hello world");
assert_eq!(sha256.digest().to_vec(), vec![
    0xb9, 0x4d, 0x27, 0xb9, 0x93, 0x4d, 0x3e, 0x08,
    0xa5, 0x2e, 0x52, 0xd7, 0xda, 0x7d, 0xab, 0xfa,
    0xc4, 0x84, 0xef, 0xe3, 0x7a, 0x53, 0x80, 0xee,
    0x90, 0x88, 0xf7, 0xac, 0xe2, 0xef, 0xcd, 0xe9,
]);

Implementations§

Source§

impl SHA256

Source

pub fn new() -> SHA256

Create new instance of SHA256 digest.

Source

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

Add input data to the digest.

Source

pub fn digest(self: &mut SHA256) -> [u8; 32]

Generate digest array.

Trait Implementations§

Source§

impl Default for SHA256

Source§

fn default() -> SHA256

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for SHA256

§

impl RefUnwindSafe for SHA256

§

impl Send for SHA256

§

impl Sync for SHA256

§

impl Unpin for SHA256

§

impl UnwindSafe for SHA256

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.