novel-api 0.19.1

Novel APIs from various sources
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use hmac::{Hmac, Mac};
use sha2::Sha256;

use crate::Error;

pub(crate) fn hmac_sha256_base64<T, E>(key: T, data: E) -> Result<String, Error>
where
    T: AsRef<[u8]>,
    E: AsRef<[u8]>,
{
    type HmacSha256 = Hmac<Sha256>;

    let mut mac = HmacSha256::new_from_slice(key.as_ref())?;
    mac.update(data.as_ref());
    Ok(base64_simd::STANDARD.encode_to_string(mac.finalize().into_bytes()))
}