Skip to content

HashFile (file hashing)

ts
function HashFile(hashType: string, fileName: string): string;

Computes the hash value of a file and returns it as a string.

ParameterTypeRequirementExplanation
hashTypestringrequiredHash algorithm: one of md5, sha1, sha128, sha256, sha384, sha512, sha3128, sha3256, sha3384, sha3512
fileNamestringrequiredFully qualified path to the file to hash
Return valueExplanation
stringThe hash value of the file, or an empty string if the operation fails

Example

ts
var hash = HashFile('sha256', '/home/user/documents/resume.pdf');
if (hash !== "") {
  Log('SHA-256 hash: ' + hash);
} else {
  Log('Hashing failed.');
}