elf_utils 0.1.4

elf_rust utils
Documentation
use std::env;
use hmac::{KeyInit, Hmac, Mac};
use sha2::Sha256;

pub(crate) fn get_fs_secret() -> String {
    env::var("FeiShu_SECRET").expect("get_fs_secret is empty")
}

pub(crate)  fn get_fs_url() -> String {
    env::var("FeiShu_WEBHOOK").expect("get_fs_url is empty")
}

pub(crate) fn gen_sign(secret: &str, timestamp: i64) -> String {
    type HmacSha256 = Hmac<Sha256>;
    let mut mac = HmacSha256::new_from_slice(format!("{}\n{}", timestamp, secret).as_bytes()).expect("HMAC can take key of any size");
    mac.update(b"");
    let result = mac.finalize();
    base64::encode(result.into_bytes())
}