Stdlib module crypto/hash.vitl

This page is a wiki-style reference for one concrete stdlib file. It explains what the file owns, where it fits in the family, and how to decide whether this is the right surface to depend on.

Visual portrait of crypto/hash.vitl
Wiki-style portrait for crypto/hash.vitl.

Family: crypto

Kind: public stdlib surface

Page style: this reference follows the same “encyclopedic card + portrait + usage contract” logic as the keyword pages, but for stdlib modules.

Summary

Overview

FieldValue
Pathcrypto/hash.vitl
Familycrypto
Kindpublic stdlib surface
Line count154
Declared procedures22
Declared forms/picks2

`crypto/hash.vitl` is a public stdlib surface inside the `crypto` family. It should be read as one focused slice of the broader family responsibility: Hashing, HMAC, randomness, key derivation, symmetric primitives, and asymmetric primitives.

Purpose

This file should be chosen because of responsibility, not because its name “sounds close enough”. Inside the crypto family, it carries one focused part of the contract and keeps that responsibility separate from neighboring concerns.

  • Use this module when keyed lookup, de-duplication, or stable addressability is part of the program contract.
  • A package manifest can be serialized first, then hashed, then optionally signed.
  • A token flow can derive a key in one boundary and use it in another without mixing concerns.

Taxonomy

Think of this page as a generated encyclopedia entry rather than a hand-written tutorial. The goal is to show what kind of module this is, how dense it is, and what reading strategy makes sense before depending on it.

  • Large algorithm surface: this file exposes many procedures and likely acts as a domain toolkit rather than a single thin wrapper.
  • Owns domain vocabulary: the module declares data shapes in addition to executable helpers, so its types are part of the contract.
  • Has tuning constants: part of the module behavior is controlled by named constants that document default precision, limits, or policy.
  • Minimal top-level dependencies: the module reads as mostly self-contained from its opening declarations.
  • Explicit export surface: the file ends with visible export declarations instead of relying only on implicit namespace discovery.

Implementation profile

This profile is inferred directly from the source text. It does not replace reading the file, but it tells you quickly whether the module is mostly declarative, loop-heavy, branch-heavy, or organized around many small exits.

SignalCountWhat it suggests
if0Branching density and local decision-making.
while0Loop-heavy or iterative implementation style.
for0Collection-style traversal at source level.
match0Variant-driven branching or grammar-style decoding.
let2Local state and intermediate value density.
give22Number of explicit exit points and result shaping.

Top-level API inventory

SurfaceItems
Proceduresmd5, md5_hex, sha1, sha1_hex, sha256, sha256_hex, sha512, sha512_hex, sha3_256, sha3_256_hex, sha3_512, sha3_512_hex
FormsHash, HashManifest
Picksnone declared at top level
ConstantsHASH_MD5, HASH_SHA1, HASH_SHA256, HASH_SHA512, HASH_SHA3_256, HASH_SHA3_512, HASH_BLAKE2B, MD5_DIGEST_SIZE, SHA1_DIGEST_SIZE, SHA256_DIGEST_SIZE, SHA512_DIGEST_SIZE, AES_ECB
Exports*

Imported surfaces

This file does not advertise a top-level `use` surface in its opening declarations. That often means it is either self-contained or an aggregation layer.

Position in family

This file is module 3 of 9 in the crypto family when ordered by path. By procedure count it ranks 2, and by line count it ranks 2. Those ranks are useful as rough signals of breadth, not as quality judgments.

Declaration map

The declaration map turns raw source into a scan-friendly catalog. It is useful when the file is large enough that a reader wants to orient by kinds of surfaces first.

LineNameKindRole
1vitte/crypto/hashspaceDeclares the namespace that anchors this file in the stdlib tree.
8HASH_MD5constDefines a named constant reused across the module.
9HASH_SHA1constDefines a named constant reused across the module.
10HASH_SHA256constDefines a named constant reused across the module.
11HASH_SHA512constDefines a named constant reused across the module.
12HASH_SHA3_256constDefines a named constant reused across the module.
13HASH_SHA3_512constDefines a named constant reused across the module.
14HASH_BLAKE2BconstDefines a named constant reused across the module.
17MD5_DIGEST_SIZEconstDefines a named constant reused across the module.
18SHA1_DIGEST_SIZEconstDefines a named constant reused across the module.
19SHA256_DIGEST_SIZEconstDefines a named constant reused across the module.
20SHA512_DIGEST_SIZEconstDefines a named constant reused across the module.
23AES_ECBconstDefines a named constant reused across the module.
24AES_CBCconstDefines a named constant reused across the module.
25AES_CTRconstDefines a named constant reused across the module.
26AES_GCMconstDefines a named constant reused across the module.
29AES_128constDefines a named constant reused across the module.
30AES_192constDefines a named constant reused across the module.
31AES_256constDefines a named constant reused across the module.
33HashformIntroduces a structured data shape that other procedures can exchange.
40HashManifestformIntroduces a structured data shape that other procedures can exchange.
47md5procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
51md5_hexprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
56sha1procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
60sha1_hexprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
65sha256procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
69sha256_hexprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
74sha512procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
78sha512_hexprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
83sha3_256procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
87sha3_256_hexprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
92sha3_512procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
96sha3_512_hexprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
101blake2bprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
105blake2b_hexprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
110hash_newprocImplements a security-sensitive transformation in the crypto boundary.
119hash_updateprocImplements a security-sensitive transformation in the crypto boundary.
123hash_finalprocImplements a security-sensitive transformation in the crypto boundary.
127hash_final_hexprocImplements a security-sensitive transformation in the crypto boundary.
131hash_versionprocImplements a security-sensitive transformation in the crypto boundary.
135hash_readyprocImplements a security-sensitive transformation in the crypto boundary.
139hash_manifestprocImplements a security-sensitive transformation in the crypto boundary.
147hash_selftestprocImplements a security-sensitive transformation in the crypto boundary.

The table is exhaustive for top-level declarations of the selected kinds. This file declares 43 matching surfaces.

Representative signatures

These signatures are shown in source order so the page keeps the feel of a reference manual, not just a keyword cloud.

  • const HASH_MD5: i32 = 1 (line 8)
  • const HASH_SHA1: i32 = 2 (line 9)
  • const HASH_SHA256: i32 = 3 (line 10)
  • const HASH_SHA512: i32 = 4 (line 11)
  • const HASH_SHA3_256: i32 = 5 (line 12)
  • const HASH_SHA3_512: i32 = 6 (line 13)
  • const HASH_BLAKE2B: i32 = 7 (line 14)
  • const MD5_DIGEST_SIZE: i32 = 16 (line 17)
  • const SHA1_DIGEST_SIZE: i32 = 20 (line 18)
  • const SHA256_DIGEST_SIZE: i32 = 32 (line 19)
  • const SHA512_DIGEST_SIZE: i32 = 64 (line 20)
  • const AES_ECB: i32 = 1 (line 23)
  • const AES_CBC: i32 = 2 (line 24)
  • const AES_CTR: i32 = 3 (line 25)
  • const AES_GCM: i32 = 4 (line 26)
  • const AES_128: i32 = 16 (line 29)
  • const AES_192: i32 = 24 (line 30)
  • const AES_256: i32 = 32 (line 31)

The list is intentionally capped here; the source file declares 42 matching signatures in total.

How to use this module

Start by reading the file as an ownership boundary. Ask three questions: what enters this module, what stable types or procedures it exports, and what adjacent module should stay outside of it.

  1. Read space and top-level imports first so the ownership boundary of crypto/hash.vitl is explicit.
  2. Scan constants before procedures; they often encode precision, limits, or policy assumptions that explain later behavior.
  3. Read declared forms and picks before algorithms so the data vocabulary is stable in your head.
  4. Traverse procedures in source order; the early helpers usually explain the naming and numeric conventions used later.
  5. Use the source landmarks section below as a table of contents when the file is large.

User example

This example is generated from the actual stdlib module surface. Its job is not to be the smallest snippet possible; its job is to show a realistic consumer-shaped file that exercises the module and mirrors the language keywords the module itself relies on.

space demo/crypto_hash
const SAMPLE_LABEL: string = "demo"
form UserReport {
  label: string,
  ready: bool
}
proc run_example() -> UserReport {
  let result = md5("sample")
  let ready: bool = hash_ready()
  let stable: bool = ready and true
    give UserReport { label: "ok", ready: true }
}
export run_example

Keyword coverage

This table makes the “all keywords of the module” requirement auditable. It compares the detected Vitte keywords in the source file with the generated consumer example above.

KeywordPresent in module sourceUsed in generated user example
spaceyesyes
constyesyes
formyesyes
procyesyes
letyesyes
giveyesyes
exportyesyes
trueyesyes
andyesyes

The generated snippet exercises every detected Vitte keyword used by this module.

Source shape

space vitte/crypto/hash
// Hash algorithm constants
const HASH_MD5: i32 = 1
const HASH_SHA1: i32 = 2
const HASH_SHA256: i32 = 3
const HASH_SHA512: i32 = 4
const HASH_SHA3_256: i32 = 5
const HASH_SHA3_512: i32 = 6
const HASH_BLAKE2B: i32 = 7
// Output sizes

The excerpt is not meant to replace the file. It exists to make the module recognizable at first glance, the same way a Wikipedia infobox helps the reader orient before reading the whole article.

Source landmarks

Large files are easier to retain when they have visible landmarks. When the source contains explicit section banners, they are surfaced here; otherwise the first major declarations are used as anchors.

  • Hash Functions Module

Source organization

When a file carries its own internal chaptering, those chapters usually reveal the intended reading order better than a flat symbol list. This section reconstructs that organization from the source itself.

Opening declarations

Top-level items: 1. Procedures: 0. Data surfaces: 0. Constants: 0.

First visible names: vitte/crypto/hash

Hash Functions Module

Top-level items: 43. Procedures: 22. Data surfaces: 2. Constants: 18.

First visible names: HASH_MD5, HASH_SHA1, HASH_SHA256, HASH_SHA512, HASH_SHA3_256, HASH_SHA3_512, HASH_BLAKE2B, MD5_DIGEST_SIZE, SHA1_DIGEST_SIZE, SHA256_DIGEST_SIZE

Complete API catalog

This catalog is the exhaustive file-level index for the module. It is intentionally closer to a generated encyclopedia appendix than to a tutorial summary.

Constants

LineNameSignatureRole
8HASH_MD5const HASH_MD5: i32 = 1Defines a named constant reused across the module.
9HASH_SHA1const HASH_SHA1: i32 = 2Defines a named constant reused across the module.
10HASH_SHA256const HASH_SHA256: i32 = 3Defines a named constant reused across the module.
11HASH_SHA512const HASH_SHA512: i32 = 4Defines a named constant reused across the module.
12HASH_SHA3_256const HASH_SHA3_256: i32 = 5Defines a named constant reused across the module.
13HASH_SHA3_512const HASH_SHA3_512: i32 = 6Defines a named constant reused across the module.
14HASH_BLAKE2Bconst HASH_BLAKE2B: i32 = 7Defines a named constant reused across the module.
17MD5_DIGEST_SIZEconst MD5_DIGEST_SIZE: i32 = 16Defines a named constant reused across the module.
18SHA1_DIGEST_SIZEconst SHA1_DIGEST_SIZE: i32 = 20Defines a named constant reused across the module.
19SHA256_DIGEST_SIZEconst SHA256_DIGEST_SIZE: i32 = 32Defines a named constant reused across the module.
20SHA512_DIGEST_SIZEconst SHA512_DIGEST_SIZE: i32 = 64Defines a named constant reused across the module.
23AES_ECBconst AES_ECB: i32 = 1Defines a named constant reused across the module.
24AES_CBCconst AES_CBC: i32 = 2Defines a named constant reused across the module.
25AES_CTRconst AES_CTR: i32 = 3Defines a named constant reused across the module.
26AES_GCMconst AES_GCM: i32 = 4Defines a named constant reused across the module.
29AES_128const AES_128: i32 = 16Defines a named constant reused across the module.
30AES_192const AES_192: i32 = 24Defines a named constant reused across the module.
31AES_256const AES_256: i32 = 32Defines a named constant reused across the module.

Data surfaces

LineNameSignatureRole
33Hashform Hash {Introduces a structured data shape that other procedures can exchange.
40HashManifestform HashManifest {Introduces a structured data shape that other procedures can exchange.

Procedures

LineNameSignatureRole
47md5proc md5(data: string) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
51md5_hexproc md5_hex(data: string) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
56sha1proc sha1(data: string) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
60sha1_hexproc sha1_hex(data: string) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
65sha256proc sha256(data: string) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
69sha256_hexproc sha256_hex(data: string) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
74sha512proc sha512(data: string) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
78sha512_hexproc sha512_hex(data: string) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
83sha3_256proc sha3_256(data: string) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
87sha3_256_hexproc sha3_256_hex(data: string) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
92sha3_512proc sha3_512(data: string) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
96sha3_512_hexproc sha3_512_hex(data: string) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
101blake2bproc blake2b(data: string, size: i32) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
105blake2b_hexproc blake2b_hex(data: string, size: i32) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
110hash_newproc hash_new(algorithm: i32) -> Hash {Implements a security-sensitive transformation in the crypto boundary.
119hash_updateproc hash_update(h: Hash, data: string) -> int {Implements a security-sensitive transformation in the crypto boundary.
123hash_finalproc hash_final(h: Hash) -> string {Implements a security-sensitive transformation in the crypto boundary.
127hash_final_hexproc hash_final_hex(h: Hash) -> string {Implements a security-sensitive transformation in the crypto boundary.
131hash_versionproc hash_version() -> string {Implements a security-sensitive transformation in the crypto boundary.
135hash_readyproc hash_ready() -> bool {Implements a security-sensitive transformation in the crypto boundary.
139hash_manifestproc hash_manifest() -> HashManifest {Implements a security-sensitive transformation in the crypto boundary.
147hash_selftestproc hash_selftest() -> bool {Implements a security-sensitive transformation in the crypto boundary.

Exports

LineNameSignatureRole
154*export *Re-exports surfaces that the module wants to expose as part of its public boundary.

Integration boundaries

Within crypto, this file should remain focused. If a future helper changes the host boundary, scheduling boundary, or data-shape boundary, it probably belongs in a neighbor module instead of being added here by convenience.

  • Family responsibility: Hashing, HMAC, randomness, key derivation, symmetric primitives, and asymmetric primitives.
  • Family architecture role: Use `crypto` when integrity, secrecy, or key management is the feature. This family should never be presented as generic formatting or utility code.

Composition guidance

Choose this module when

  • Choose crypto/hash.vitl when the main question is owned by this module rather than by transport, storage, orchestration, or user-interface code.
  • Use this module when keyed lookup, de-duplication, or stable addressability is part of the program contract.
  • A package manifest can be serialized first, then hashed, then optionally signed.
  • A token flow can derive a key in one boundary and use it in another without mixing concerns.

Pause before extending it when

  • Avoid extending this file when the new helper mostly changes the boundary to host I/O, runtime coordination, or foreign integration instead of staying inside crypto.
  • Check nearby modules such as crypto/asymmetric.vitl, crypto/hashing.vitl, crypto/hmac.vitl before adding convenience wrappers here.

Relationship table

This table keeps the page closer to a real encyclopedia entry: a module is easier to understand when compared with its nearest alternatives in the same family.

NeighborProceduresData surfacesWhy compare it
crypto/asymmetric.vitl100Shares the same family boundary but carries a distinct slice of responsibility.
crypto/hashing.vitl100Shares the same family boundary but carries a distinct slice of responsibility.
crypto/hmac.vitl82Shares the same family boundary but carries a distinct slice of responsibility.
crypto/keyderivation.vitl71Shares the same family boundary but carries a distinct slice of responsibility.
crypto/random.vitl131Shares the same family boundary but carries a distinct slice of responsibility.
crypto/symmetric.vitl100Shares the same family boundary but carries a distinct slice of responsibility.
crypto/utils.vitl111Shares the same family boundary but carries a distinct slice of responsibility.
crypto.vitl446Shares the same family boundary but carries a distinct slice of responsibility.

Neighbor modules