Reference · reference

hash module

1 min read · 2026-09-02 · config-weave 0.1.0

use hash computes cryptographic digests of strings and files. Every function returns the digest as a lowercase hexadecimal string. The string variants cannot fail. The file variants return Result[string, string] and fail when the file cannot be opened or read. MD5 is provided for interoperability with legacy checksums only.

sha256 and sha256_file

rust
hash::sha256(s: string) -> string
hash::sha256_file(path: string) -> Result[string, string]

SHA-256 of a string, or of a file's contents.

sha512 and sha512_file

rust
hash::sha512(s: string) -> string
hash::sha512_file(path: string) -> Result[string, string]

SHA-512 of a string, or of a file's contents.

md5 and md5_file

rust
hash::md5(s: string) -> string
hash::md5_file(path: string) -> Result[string, string]

MD5 of a string, or of a file's contents. Use it only to compare against a checksum that was published as MD5.

rust
use hash

let digest = hash::sha256_file("/tmp/tool.tar.gz")?
if digest != expected { return Err("checksum mismatch") }