Vital.sandbox
File

file.hash

Shared

Retrieves the hash of a specified file


Syntax

local hash = 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 :resourcename to resolve relative to another running resource's directory
  • Example:resource_a/files/images/test.png accesses files/images/test.png inside resource_a

Parameters

TypeNameDescription
stringpathFile path to hash
stringmodeHashing algorithm to use - same modes as used in crypto.hash

Returns

TypeNameDescription
string / boolhashComputed file hash on successful execution, or false on failure

Examples

Hash a file within the current resource
engine.print("info", "File hash:", file.hash("files/images/test.png", "SHA256"))
Hash a file from another running resource
engine.print("info", "File hash:", file.hash(":resource_a/files/images/test.png", "SHA256"))

On this page