File size: 1,320 Bytes
4953a87 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ||| SHA-256 via C FFI (OpenSSL libcrypto)
|||
||| Copyright (C) 2026 SNAPKITTYWEST / SnapKitty (Jessica)
||| License: BSL-1.1 / AGPL-3.0 / MPL-2.0
module Hash
-- ββ C FFI ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
%foreign "C:idris2_sha256_file,clone_gate_hash"
prim__sha256File : String -> PrimIO String
%foreign "C:idris2_sha256_string,clone_gate_hash"
prim__sha256String : String -> PrimIO String
-- ββ Public API βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
||| SHA-256 of a file's byte content. Returns 64-char lowercase hex.
export
sha256File : HasIO io => String -> io String
sha256File path = primIO (prim__sha256File path)
||| SHA-256 of a raw string. Returns 64-char lowercase hex.
export
sha256String : HasIO io => String -> io String
sha256String s = primIO (prim__sha256String s)
||| The zero digest (unsealed sentinel).
export
zeroDigest : String
zeroDigest = replicate 64 '0'
||| True if a digest is the unsealed zero sentinel.
export
isUnsealed : String -> Bool
isUnsealed d = d == zeroDigest
|