literate-crypto 0.0.3

Literate Cryptography by 12hbender
Documentation
use crate::{Hmac, Mac, Sha1, Sha256};

#[test]
fn hmac_sha1() {
    let mut hmac = Hmac::new(Sha1::default());
    let tag = hmac.mac(b"The quick brown fox jumps over the lazy dog", b"key");
    assert_eq!(
        tag,
        [
            0xde, 0x7c, 0x9b, 0x85, 0xb8, 0xb7, 0x8a, 0xa6, 0xbc, 0x8a, 0x7a, 0x36, 0xf7, 0x0a,
            0x90, 0x70, 0x1c, 0x9d, 0xb4, 0xd9,
        ],
    );
}

#[test]
fn hmac_sha256() {
    let mut hmac = Hmac::new(Sha256::default());
    let tag = hmac.mac(b"The quick brown fox jumps over the lazy dog", b"key");
    assert_eq!(
        tag,
        [
            0xf7, 0xbc, 0x83, 0xf4, 0x30, 0x53, 0x84, 0x24, 0xb1, 0x32, 0x98, 0xe6, 0xaa, 0x6f,
            0xb1, 0x43, 0xef, 0x4d, 0x59, 0xa1, 0x49, 0x46, 0x17, 0x59, 0x97, 0x47, 0x9d, 0xbc,
            0x2d, 0x1a, 0x3c, 0xd8,
        ],
    );
}