Availability::- use_module(library(sha)).
(can be autoloaded)
sha_hash(+Data,
-Hash, +Options)Hash is the SHA hash of Data. Data is either an atom, packed
string or list of character codes. Hash is unified with a
list of bytes (integers in the range 0..255) representing the hash. See
hash_atom/2
to convert this into the more commonly seen hexadecimal representation.
The conversion is controlled by Options:
- algorithm(+Algorithm)
- One of
sha1
(default), sha224
, sha256
,
sha384
or sha512
- encoding(+Encoding)
- This option defines the mapping from Prolog (Unicode) text to bytes on
which the SHA algorithm is performed. It has two values. The defualt is
utf8
,
which implies that Unicode text is encoded as UTF-8 bytes. This option
can deal with any atom. The alternative is
octet
, which implies that the text is considered as a
sequence of bytes. This is suitable for e.g., atoms that represent
binary data. An error is raised if the text contains code-points outside
the range 0..255.