util.file.hash
Shared
Retrieves the hash of a specified file
Syntax
local hash = util.file.hash(
path,
mode
)Prefix the path with :resourcename to access files from another running resource.
- Local path — resolves relative to the current resource's directory.
- Cross-resource path — prefix with
:resourcenameto resolve relative to another running resource's directory. - Example —
:resource_a/files/images/test.pngaccessesfiles/images/test.pnginsideresource_a.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | File path to hash |
string | mode | Hashing algorithm to use - same modes as used in util.crypto.hash |
Returns
| Type | Name | Description |
|---|---|---|
string | bool | hash | Computed file hash on successful execution, false otherwise |
Examples
core.engine.print("info", "File hash:", util.file.hash("files/images/test.png", "sha256"))core.engine.print("info", "File hash:", util.file.hash(":resource_a/files/images/test.png", "sha256"))