blob: f9137362a56c0110f9d2356e271640a37a207e5f [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrad59c3892019-11-28 20:53:39 +01002 #include <tls.h>
MG Mud User88f12472016-06-24 23:31:02 +02003
4 string hash(int method, string arg [, int iterations ] )
Zesstrad59c3892019-11-28 20:53:39 +01005 string hash(int method, bytes arg [, int iterations ] )
MG Mud User88f12472016-06-24 23:31:02 +02006 string hash(int method, int * arg [, int iterations ] )
7
Zesstra715ec202025-07-09 22:18:31 +02008DESCRIPTION
9 Calculate the hash from <arg> as determined by <method>. The hash is
10 calculated with <iterations> iterations, default is 1 iteration.
11 If <arg> is a string, it will be converted to a UTF-8 byte sequence
12 of which then the hash will be created.
MG Mud User88f12472016-06-24 23:31:02 +020013
Zesstra715ec202025-07-09 22:18:31 +020014 <method> is one of the TLS_HASH_ constants defined in tls.h; not
15 all recognized methods may be supported for a given driven:
MG Mud User88f12472016-06-24 23:31:02 +020016
17 TLS_HASH_SHA1 (1)
18 TLS_HASH_SHA224 (2)
19 TLS_HASH_SHA256 (3)
20 TLS_HASH_SHA384 (4)
21 TLS_HASH_SHA512 (5)
22 TLS_HASH_MD5 (6)
23 TLS_HASH_RIPEMD160 (7)
24
Zesstra715ec202025-07-09 22:18:31 +020025 If the driver is compiled without OpenSSL or GCrypt support
26 only TLS_HASH_SHA1 and TLS_HASH_MD5 are available.
Zesstrad59c3892019-11-28 20:53:39 +010027
Zesstra715ec202025-07-09 22:18:31 +020028 The efun costs 10 ticks per iteration.
Zesstrad59c3892019-11-28 20:53:39 +010029
MG Mud User88f12472016-06-24 23:31:02 +020030
Zesstra715ec202025-07-09 22:18:31 +020031EXAMPLES
MG Mud User88f12472016-06-24 23:31:02 +020032 string s;
33
34 s = hash(TLS_HASH_SHA1, "Hello", 2);
35 s = hash(TLS_HASH_SHA1, ({ 'H', 'e', 'l', 'l', 'o' }) )
36
Zesstra715ec202025-07-09 22:18:31 +020037HISTORY
38 Introduced in LDMud 3.3.714.
39 LDMud 3.3.719 added the iteration-based evaluation cost.
MG Mud User88f12472016-06-24 23:31:02 +020040
Zesstra715ec202025-07-09 22:18:31 +020041SEE ALSO
MG Mud User88f12472016-06-24 23:31:02 +020042 crypt(E), md5(E), md5_crypt(E), sha1(E), hmac(E)