ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. fileGetHash

Function

fileGetHash

Returns a hash of the file content in hexadecimal. Useful to check whether a file has changed. The hash is computed from the content as UTF-8 text, so for binary files it may differ from hashes made by other tools. Algorithms: "md5", "sha1", "sha224", "sha256", "sha384", "sha512".

Syntax

string fileGetHash(file/string fileOrPath [, string algorithm = "md5"])

Arguments

fileOrPathfile/string
A handle or a path.
algorithmstring, optional = "md5"
Hash algorithm.

Differences from MTA:SA

  • These MTA:SA arguments are not here: table options = nil

In MTA:SA

fileGetHash(file theFile, string algorithm, table options = nil)

Returns

The hash, or false.

Example

outputDebugString("config.json: " .. tostring(fileGetHash("config.json", "sha256")))

See also