Struct HMac

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

Main hmac-sha256 structure.

Usage:

extern crate dumb_crypto;

use::dumb_crypto::hmac::HMac;

let mut hmac = HMac::new(b"secret key");

hmac.update(b"hello world");
assert_eq!(hmac.digest().to_vec(), vec![
    0xc6, 0x1b, 0x51, 0x98, 0xdf, 0x58, 0x63, 0x9e,
    0xdb, 0x98, 0x92, 0x51, 0x47, 0x56, 0xb8, 0x9a,
    0x36, 0x85, 0x6d, 0x82, 0x6e, 0x5d, 0x85, 0x02,
    0x3a, 0xb1, 0x81, 0xb4, 0x8e, 0xa5, 0xd0, 0x18,
]);

Implementations§

Source§

impl HMac

Source

pub fn new(key: &[u8]) -> HMac

Create new instance of Hmac-sha256 message authentication.

Arguments:

  • key - secret key
Source

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

Add input data to the digest.

Source

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

Generate digest array.

Auto Trait Implementations§

§

impl Freeze for HMac

§

impl RefUnwindSafe for HMac

§

impl Send for HMac

§

impl Sync for HMac

§

impl Unpin for HMac

§

impl UnwindSafe for HMac

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.