SYNOPSIS
#include <tls.h>
string hash(int method, string arg [, int iterations ] )
string hash(int method, bytes arg [, int iterations ] )
string hash(int method, int * arg [, int iterations ] )
DESCRIPTION
Calculate the hash from <arg> as determined by <method>. The hash is
calculated with <iterations> iterations, default is 1 iteration.
If <arg> is a string, it will be converted to a UTF-8 byte sequence
of which then the hash will be created.
<method> is one of the TLS_HASH_ constants defined in tls.h; not
all recognized methods may be supported for a given driven:
TLS_HASH_SHA1 (1)
TLS_HASH_SHA224 (2)
TLS_HASH_SHA256 (3)
TLS_HASH_SHA384 (4)
TLS_HASH_SHA512 (5)
TLS_HASH_MD5 (6)
TLS_HASH_RIPEMD160 (7)
If the driver is compiled without OpenSSL or GCrypt support
only TLS_HASH_SHA1 and TLS_HASH_MD5 are available.
The efun costs 10 ticks per iteration.
EXAMPLES
string s;
s = hash(TLS_HASH_SHA1, "Hello", 2);
s = hash(TLS_HASH_SHA1, ({ 'H', 'e', 'l', 'l', 'o' }) )
HISTORY
Introduced in LDMud 3.3.714.
LDMud 3.3.719 added the iteration-based evaluation cost.
SEE ALSO
crypt(E), md5(E), md5_crypt(E), sha1(E), hmac(E)
|