Calculate the hash value of the string str using the hash function hfun.
The available hash functions are given in the table below.
Message-Digest Algorithm 2 (RFC 1319).
Message-Digest Algorithm 4 (RFC 1320).
Message-Digest Algorithm 5 (RFC 1321).
Secure Hash Algorithm 1 (RFC 3174)
Secure Hash Algorithm 2 (224 Bits, RFC 3874)
Secure Hash Algorithm 2 (256 Bits, RFC 6234)
Secure Hash Algorithm 2 (384 Bits, RFC 6234)
Secure Hash Algorithm 2 (512 Bits, RFC 6234)
To calculate for example the MD5 hash value of the string
"abc"
the hash
function is called as follows:
hash ("md5", "abc") -| ans = 900150983cd24fb0d6963f7d28e17f72
For the same string, the SHA-1 hash value is calculated with:
hash ("sha1", "abc") -| ans = a9993e364706816aba3e25717850c26c9cd0d89d
And to compute the hash value of a file, e.g., file = "file.txt"
,
call hash
in combination with the fileread
:
hash ("md5", fileread (file));
Package: octave