nupp.digest
Provider-selected fixed-output message digests.
create("sha256") uses the descriptor retained when this module loads. Setup selects a typed provider catalog before requiring this facade. Its entries override matching built-ins; other built-ins remain available. Descriptor names and sizes must agree with the algorithm. No context operation resolves services. digest() returns raw bytes, digest(destination) writes into an existing writable byte span, and hexDigest() returns lowercase hexadecimal. Each final operation consumes the digest. Dropping an unfinished digest closes its provider context. MD5 and SHA-1 are for legacy interoperability only.
Module contents
Types
| Type | Kind | Description |
|---|---|---|
Algorithm | record | Immutable algorithm metadata and a factory for independent digest contexts. |
Digest | interface | An owned incremental digest, consumed by either finalization overload. |
Functions
| Function | Kind | Description |
|---|---|---|
algorithm | function | Requires an available algorithm descriptor. |
algorithms | function | Lists canonical available names in ascending order. |
create | function | Creates fresh incremental digest state. |
digest | function | Computes one raw digest. |
hexDigest | function | Computes one lowercase hexadecimal digest. |
lookup | function | Looks up an algorithm without constructing mutable provider state. |
Types#
Algorithmrecord#
record Algorithm
readonly name: string
readonly digestSize: integer
function create(self): Digest end
endImmutable algorithm metadata and a factory for independent digest contexts.
Methods
create#
Creates independent owned state for this algorithm.
Arguments
| Name | Type | Description |
|---|---|---|
self | any |
Returns
| Type | Description |
|---|---|
Digest | the unfinished digest context |
Fields
Digestinterface#
affine interface Digest is nupp.Closeable
terminal close: function(takes self: Digest): nil
algorithm: function(self: Digest): string
digestSize: function(self: Digest): integer
update: function(exclusive self: Digest, bytes: string): nil
updateSpan: function(exclusive self: Digest, borrows bytes: span.ByteSpan): nil
digest: function(takes self: Digest): string
& function(takes self: Digest, exclusive destination: span.ByteWriteSpan): integer
hexDigest: function(takes self: Digest): string
endAn owned incremental digest, consumed by either finalization overload.
Methods
close#
Consumes an unfinished context and releases provider state without suspension.
Arguments
| Name | Type | Description |
|---|---|---|
takes self | Digest |
Returns
| Type | Description |
|---|---|
nil |
algorithm#
Returns the canonical algorithm name retained at creation.
Arguments
| Name | Type | Description |
|---|---|---|
self | Digest |
Returns
| Type | Description |
|---|---|
string |
digestSize#
digestSize: function(self: Digest): integerReturns the fixed output size in bytes.
Arguments
| Name | Type | Description |
|---|---|---|
self | Digest |
Returns
| Type | Description |
|---|---|
integer |
update#
Processes raw bytes without retaining a borrowed input.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive self | Digest | |
bytes | string |
Returns
| Type | Description |
|---|---|
nil |
updateSpan#
Processes a borrowed byte view without retaining it.
Arguments
| Name | Type | Description |
|---|---|---|
exclusive self | Digest | |
borrows bytes | span.ByteSpan |
Returns
| Type | Description |
|---|---|
nil |
digest#
digest: function(takes self: Digest): string
& function(takes self: Digest, exclusive destination: span.ByteWriteSpan): integerConsumes this context and returns raw bytes, or writes the fixed-size prefix of destination and returns its byte count. Always closes state.
Arguments
| Name | Type | Description |
|---|---|---|
takes self | Digest | |
exclusive destination | span.ByteWriteSpan |
Returns
| Type | Description |
|---|---|
integer |
Functions#
algorithmfunction#
Requires an available algorithm descriptor.
Arguments
| Name | Type | Description |
|---|---|---|
name | string | the canonical algorithm name |
Returns
| Type | Description |
|---|---|
Algorithm | the selected descriptor |
Raises
when the algorithm is unavailable or its provider is invalid
algorithmsfunction#
function algorithms(): {string}Lists canonical available names in ascending order.
Returns
| Type | Description |
|---|---|
{string} | the available canonical names |
createfunction#
Creates fresh incremental digest state.
Arguments
| Name | Type | Description |
|---|---|---|
name | string | the canonical algorithm name |
Returns
| Type | Description |
|---|---|
Digest | an owned unfinished digest |
Raises
when the algorithm is unavailable or cannot be initialized
digestfunction#
Computes one raw digest.
Arguments
| Name | Type | Description |
|---|---|---|
name | string | the canonical algorithm name |
bytes | string | the message bytes |
Returns
| Type | Description |
|---|---|
string | the raw fixed-size digest bytes |
hexDigestfunction#
Computes one lowercase hexadecimal digest.
Arguments
| Name | Type | Description |
|---|---|---|
name | string | the canonical algorithm name |
bytes | string | the message bytes |
Returns
| Type | Description |
|---|---|
string | the lowercase hexadecimal digest |
lookupfunction#
Looks up an algorithm without constructing mutable provider state.
Arguments
| Name | Type | Description |
|---|---|---|
name | string | the canonical algorithm name |
Returns
| Type | Description |
|---|---|
Algorithm? | the descriptor, or nil when unavailable |