Skip to main content

hmac_digest

Function hmac_digest 

Source
pub fn hmac_digest<'py>(
    py: Python<'py>,
    algorithm: &str,
    key: &[u8],
    data: &[u8],
) -> PyResult<Bound<'py, PyBytes>>
Expand description

Compute an HMAC digest and return the raw MAC bytes.

algorithm must be one of "sha1", "sha224", "sha256", "sha384", "sha512", or "md5".

import synta

key  = b"secret"
data = b"hello world"
mac  = synta.hmac_digest("sha256", key, data)
print(mac.hex())