filesha512 function reference
This topic provides reference information about the filesha512
function, which calculates the SHA-512 hash of a file's contents.
Introduction
The filesha512
is a variant of sha512
that hashes the contents of a given file rather than a literal string.
This is similar to sha512(file(filename))
, but
because file
accepts only UTF-8 text it cannot be used to
create hashes for binary files.
Syntax
Use the filesha512
function with the following syntax:
The path
is the relative or absolute file path to the file whose SHA-512 hash you want to compute.
In the following example, the function returns the SHA-512 value of example.txt
.
Example use case
In the following example, the filesha512
function computes the SHA-512 hash of the file example.txt
located in the current module's directory.
Related functions
sha512
computes the SHA-512 hash of a given string and encodes it with hexadecimal digits.filesha256
computes the SHA-1 hash of a given file and encodes it with hexadecimal digits.filesha1
computes the SHA-1 hash of a given file and encodes it with hexadecimal digits.