crypto
Package crypto.
SHA-256, HMAC-SHA256, and a CSPRNG over OpenSSL. Hash and HMAC are infallible on valid inputs and return bytes directly; rand can fail and returns result[bytes, str].
import "crypto";
let h: bytes = crypto.sha256(b"abc"); // 32 bytes
let m: bytes = crypto.hmac_sha256(key, msg); // 32 bytes
let r = crypto.rand(32);
guard let b = r else let e = err_of(r) {
log.error("rand failed: " + e);
}