pub fn compute_digest(
content: &[u8],
hash: DigestHash,
encoding: DigestEncoding,
) -> StringExpand description
Computes a cryptographic digest of content.
This is a low-level function for computing digests. For descriptor
digests, prefer using the Descriptor::digest method which knows
the correct content range to hash.
§Arguments
content- The content to hashhash- The hash algorithm to useencoding- The output encoding format
§Returns
The digest as a string in the specified encoding.
§Example
use stem_rs::descriptor::{compute_digest, DigestHash, DigestEncoding};
let content = b"test content";
// SHA-1 in hex
let sha1_hex = compute_digest(content, DigestHash::Sha1, DigestEncoding::Hex);
assert_eq!(sha1_hex.len(), 40);
// SHA-256 in base64
let sha256_b64 = compute_digest(content, DigestHash::Sha256, DigestEncoding::Base64);