The most important predicates to compute hashes are:
- [det]crypto_data_hash(+Data, -Hash, +Options)
- Hash is the hash of Data. The conversion is
controlled by Options:
- One of
blake2b512. The BLAKE digest algorithms require OpenSSL 1.1.0 or greater, and the SHA-3 algorithms require OpenSSL 1.1.1 or greater. The default is a cryptographically secure algorithm. If you specify a variable, then that variable is unified with the algorithm that was used.
- If Data is a sequence of character codes, this must be
translated into a sequence of bytes, because that is what the
hashing requires. The default encoding is
utf8. The other meaningful value is
octet, claiming that Data contains raw bytes.
- If this option is specified, a hash-based message authentication code (HMAC) is computed, using the specified Key which is either an atom, string or list of bytes. Any of the available digest algorithms can be used with this option. The cryptographic strength of the HMAC depends on that of the chosen algorithm and also on the key. This option requires OpenSSL 1.1.0 or greater.
Data is either an atom, string or code-list Hash is an atom that represents the hash in hexadecimal encoding.
- [det]crypto_file_hash(+File, -Hash, +Options)
- True if Hash is the hash of the content of File. For Options, see crypto_data_hash/3.