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.
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
- Purpose
- Taxonomy
- Implementation profile
- Top-level API inventory
- Position in family
- Declaration map
- Representative signatures
- How to use this module
- User example
- Keyword coverage
- Source shape
- Source landmarks
- Source organization
- Complete API catalog
- Integration boundaries
- Composition guidance
- Relationship table
- Neighbor modules
Overview
| Field | Value |
|---|---|
| Path | crypto/hash.vitl |
| Family | crypto |
| Kind | public stdlib surface |
| Line count | 154 |
| Declared procedures | 22 |
| Declared forms/picks | 2 |
`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.
| Signal | Count | What it suggests |
|---|---|---|
if | 0 | Branching density and local decision-making. |
while | 0 | Loop-heavy or iterative implementation style. |
for | 0 | Collection-style traversal at source level. |
match | 0 | Variant-driven branching or grammar-style decoding. |
let | 2 | Local state and intermediate value density. |
give | 22 | Number of explicit exit points and result shaping. |
Top-level API inventory
| Surface | Items |
|---|---|
| Procedures | md5, md5_hex, sha1, sha1_hex, sha256, sha256_hex, sha512, sha512_hex, sha3_256, sha3_256_hex, sha3_512, sha3_512_hex |
| Forms | Hash, HashManifest |
| Picks | none declared at top level |
| Constants | 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, 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.
| Line | Name | Kind | Role |
|---|---|---|---|
| 1 | vitte/crypto/hash | space | Declares the namespace that anchors this file in the stdlib tree. |
| 8 | HASH_MD5 | const | Defines a named constant reused across the module. |
| 9 | HASH_SHA1 | const | Defines a named constant reused across the module. |
| 10 | HASH_SHA256 | const | Defines a named constant reused across the module. |
| 11 | HASH_SHA512 | const | Defines a named constant reused across the module. |
| 12 | HASH_SHA3_256 | const | Defines a named constant reused across the module. |
| 13 | HASH_SHA3_512 | const | Defines a named constant reused across the module. |
| 14 | HASH_BLAKE2B | const | Defines a named constant reused across the module. |
| 17 | MD5_DIGEST_SIZE | const | Defines a named constant reused across the module. |
| 18 | SHA1_DIGEST_SIZE | const | Defines a named constant reused across the module. |
| 19 | SHA256_DIGEST_SIZE | const | Defines a named constant reused across the module. |
| 20 | SHA512_DIGEST_SIZE | const | Defines a named constant reused across the module. |
| 23 | AES_ECB | const | Defines a named constant reused across the module. |
| 24 | AES_CBC | const | Defines a named constant reused across the module. |
| 25 | AES_CTR | const | Defines a named constant reused across the module. |
| 26 | AES_GCM | const | Defines a named constant reused across the module. |
| 29 | AES_128 | const | Defines a named constant reused across the module. |
| 30 | AES_192 | const | Defines a named constant reused across the module. |
| 31 | AES_256 | const | Defines a named constant reused across the module. |
| 33 | Hash | form | Introduces a structured data shape that other procedures can exchange. |
| 40 | HashManifest | form | Introduces a structured data shape that other procedures can exchange. |
| 47 | md5 | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 51 | md5_hex | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 56 | sha1 | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 60 | sha1_hex | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 65 | sha256 | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 69 | sha256_hex | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 74 | sha512 | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 78 | sha512_hex | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 83 | sha3_256 | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 87 | sha3_256_hex | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 92 | sha3_512 | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 96 | sha3_512_hex | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 101 | blake2b | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 105 | blake2b_hex | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 110 | hash_new | proc | Implements a security-sensitive transformation in the crypto boundary. |
| 119 | hash_update | proc | Implements a security-sensitive transformation in the crypto boundary. |
| 123 | hash_final | proc | Implements a security-sensitive transformation in the crypto boundary. |
| 127 | hash_final_hex | proc | Implements a security-sensitive transformation in the crypto boundary. |
| 131 | hash_version | proc | Implements a security-sensitive transformation in the crypto boundary. |
| 135 | hash_ready | proc | Implements a security-sensitive transformation in the crypto boundary. |
| 139 | hash_manifest | proc | Implements a security-sensitive transformation in the crypto boundary. |
| 147 | hash_selftest | proc | Implements 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.
- Read
spaceand top-level imports first so the ownership boundary ofcrypto/hash.vitlis explicit. - Scan constants before procedures; they often encode precision, limits, or policy assumptions that explain later behavior.
- Read declared forms and picks before algorithms so the data vocabulary is stable in your head.
- Traverse procedures in source order; the early helpers usually explain the naming and numeric conventions used later.
- 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.
| Keyword | Present in module source | Used in generated user example |
|---|---|---|
space | yes | yes |
const | yes | yes |
form | yes | yes |
proc | yes | yes |
let | yes | yes |
give | yes | yes |
export | yes | yes |
true | yes | yes |
and | yes | yes |
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
| Line | Name | Signature | Role |
|---|---|---|---|
| 8 | HASH_MD5 | const HASH_MD5: i32 = 1 | Defines a named constant reused across the module. |
| 9 | HASH_SHA1 | const HASH_SHA1: i32 = 2 | Defines a named constant reused across the module. |
| 10 | HASH_SHA256 | const HASH_SHA256: i32 = 3 | Defines a named constant reused across the module. |
| 11 | HASH_SHA512 | const HASH_SHA512: i32 = 4 | Defines a named constant reused across the module. |
| 12 | HASH_SHA3_256 | const HASH_SHA3_256: i32 = 5 | Defines a named constant reused across the module. |
| 13 | HASH_SHA3_512 | const HASH_SHA3_512: i32 = 6 | Defines a named constant reused across the module. |
| 14 | HASH_BLAKE2B | const HASH_BLAKE2B: i32 = 7 | Defines a named constant reused across the module. |
| 17 | MD5_DIGEST_SIZE | const MD5_DIGEST_SIZE: i32 = 16 | Defines a named constant reused across the module. |
| 18 | SHA1_DIGEST_SIZE | const SHA1_DIGEST_SIZE: i32 = 20 | Defines a named constant reused across the module. |
| 19 | SHA256_DIGEST_SIZE | const SHA256_DIGEST_SIZE: i32 = 32 | Defines a named constant reused across the module. |
| 20 | SHA512_DIGEST_SIZE | const SHA512_DIGEST_SIZE: i32 = 64 | Defines a named constant reused across the module. |
| 23 | AES_ECB | const AES_ECB: i32 = 1 | Defines a named constant reused across the module. |
| 24 | AES_CBC | const AES_CBC: i32 = 2 | Defines a named constant reused across the module. |
| 25 | AES_CTR | const AES_CTR: i32 = 3 | Defines a named constant reused across the module. |
| 26 | AES_GCM | const AES_GCM: i32 = 4 | Defines a named constant reused across the module. |
| 29 | AES_128 | const AES_128: i32 = 16 | Defines a named constant reused across the module. |
| 30 | AES_192 | const AES_192: i32 = 24 | Defines a named constant reused across the module. |
| 31 | AES_256 | const AES_256: i32 = 32 | Defines a named constant reused across the module. |
Data surfaces
| Line | Name | Signature | Role |
|---|---|---|---|
| 33 | Hash | form Hash { | Introduces a structured data shape that other procedures can exchange. |
| 40 | HashManifest | form HashManifest { | Introduces a structured data shape that other procedures can exchange. |
Procedures
| Line | Name | Signature | Role |
|---|---|---|---|
| 47 | md5 | proc md5(data: string) -> string { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 51 | md5_hex | proc md5_hex(data: string) -> string { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 56 | sha1 | proc sha1(data: string) -> string { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 60 | sha1_hex | proc sha1_hex(data: string) -> string { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 65 | sha256 | proc sha256(data: string) -> string { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 69 | sha256_hex | proc sha256_hex(data: string) -> string { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 74 | sha512 | proc sha512(data: string) -> string { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 78 | sha512_hex | proc sha512_hex(data: string) -> string { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 83 | sha3_256 | proc sha3_256(data: string) -> string { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 87 | sha3_256_hex | proc 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. |
| 92 | sha3_512 | proc sha3_512(data: string) -> string { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 96 | sha3_512_hex | proc 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. |
| 101 | blake2b | proc 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. |
| 105 | blake2b_hex | proc 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. |
| 110 | hash_new | proc hash_new(algorithm: i32) -> Hash { | Implements a security-sensitive transformation in the crypto boundary. |
| 119 | hash_update | proc hash_update(h: Hash, data: string) -> int { | Implements a security-sensitive transformation in the crypto boundary. |
| 123 | hash_final | proc hash_final(h: Hash) -> string { | Implements a security-sensitive transformation in the crypto boundary. |
| 127 | hash_final_hex | proc hash_final_hex(h: Hash) -> string { | Implements a security-sensitive transformation in the crypto boundary. |
| 131 | hash_version | proc hash_version() -> string { | Implements a security-sensitive transformation in the crypto boundary. |
| 135 | hash_ready | proc hash_ready() -> bool { | Implements a security-sensitive transformation in the crypto boundary. |
| 139 | hash_manifest | proc hash_manifest() -> HashManifest { | Implements a security-sensitive transformation in the crypto boundary. |
| 147 | hash_selftest | proc hash_selftest() -> bool { | Implements a security-sensitive transformation in the crypto boundary. |
Exports
| Line | Name | Signature | Role |
|---|---|---|---|
| 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.vitlwhen 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.vitlbefore 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.
| Neighbor | Procedures | Data surfaces | Why compare it |
|---|---|---|---|
crypto/asymmetric.vitl | 10 | 0 | Shares the same family boundary but carries a distinct slice of responsibility. |
crypto/hashing.vitl | 10 | 0 | Shares the same family boundary but carries a distinct slice of responsibility. |
crypto/hmac.vitl | 8 | 2 | Shares the same family boundary but carries a distinct slice of responsibility. |
crypto/keyderivation.vitl | 7 | 1 | Shares the same family boundary but carries a distinct slice of responsibility. |
crypto/random.vitl | 13 | 1 | Shares the same family boundary but carries a distinct slice of responsibility. |
crypto/symmetric.vitl | 10 | 0 | Shares the same family boundary but carries a distinct slice of responsibility. |
crypto/utils.vitl | 11 | 1 | Shares the same family boundary but carries a distinct slice of responsibility. |
crypto.vitl | 44 | 6 | Shares the same family boundary but carries a distinct slice of responsibility. |