l0.DependencyControl.hash¶
Functions¶
getDigest ¶
Computes the digest of a string under the given algorithm. Accepts arbitrary binary data: Lua strings are byte-safe, so any byte sequence (e.g. a file read in binary mode) hashes correctly. A raw FFI buffer must be converted with ffi.string(buf, len) first. Suitable for file integrity verification; not for security-sensitive use.
| param | type | description |
|---|---|---|
| hashType | HashType | The hash algorithm to use. |
| data | string |
The input bytes (may be binary). |
Returns:
digeststring? — A lowercase hex digest, or nil on invalid input.errstring?
verify ¶
Checks whether a string hashes to an expected digest under the given algorithm.
| param | type | description |
|---|---|---|
| hashType | HashType | The hash algorithm to use. |
| data | string |
The input bytes to hash. |
| expected | string |
The expected hex digest (compared case-insensitively). |
Returns:
matchboolean? — True on match, false on mismatch, or nil on error.errstring? — The mismatch detail or error message.
getObjectHash ¶
Produces a deterministic SHA-1 hash of a (possibly nested) Lua value. Table keys are sorted before hashing, so field ordering never affects the result; pass an object pruned to just the fields you care about to obtain a stable content signature that ignores irrelevant differences. Useful for cheaply detecting whether semantic content changed.
| param | type | description |
|---|---|---|
| value | any |
The value to hash. |
Returns:
hashstring— A 40-character lowercase SHA-1 hex digest.
Fields¶
| field | type | description |
|---|---|---|
| sha1Backend | string |
Enums¶
HashType ¶
| member | value | description |
|---|---|---|
| Sha1 | "sha1" |
SHA-1, a 40-character lowercase hex digest |