// //------------------ DOK FILE -------------------------------------------------- +Header core.crypto.hash =pkg core.crypto.hash =title core.crypto.hash =short =desc This package contains useful functions for hashing: - hash a full string in one call: [[md5]], [[sha1]], [[sha256]], ... - compute a HMAC in one call for any hash algorithm: [[hmacMd5]], [[hmacSha1]], [[hmacSha256]], ... More information about [HMAC, hash-based message authentication code](https://en.wikipedia.org/wiki/HMAC) on Wikipedia. // // //------------------ PROTO ----------------------------------------------------- hmacMd5 +Proto hmacMd5 =type fun Str Str -> Str =mode function =pkg core.crypto.hash =impl mcy =link =desc Computes a md5 HMAC for a given key and a given string. // +arg key =type Str =desc the binary representation of the key // +arg msg =type Str =desc the message to process // +arg result =type Str =desc the resulting binary string // // //------------------ PROTO ----------------------------------------------------- hmacSha1 +Proto hmacSha1 =type fun Str Str -> Str =mode function =pkg core.crypto.hash =impl mcy =link =desc Computes a sha1 HMAC for a given key and a given string. // +arg key =type Str =desc the binary representation of the key // +arg msg =type Str =desc the message to process // +arg result =type Str =desc the resulting binary string // // //------------------ PROTO ----------------------------------------------------- hmacSha256 +Proto hmacSha256 =type fun Str Str -> Str =mode function =pkg core.crypto.hash =impl mcy =link =desc Computes a sha256 HMAC for a given key and a given string. // +arg key =type Str =desc the binary representation of the key // +arg msg =type Str =desc the message to process // +arg result =type Str =desc the resulting binary string // // //------------------ PROTO ----------------------------------------------------- hmacSha384 +Proto hmacSha384 =type fun Str Str -> Str =mode function =pkg core.crypto.hash =impl mcy =link =desc Computes a sha384 HMAC for a given key and a given string. // +arg key =type Str =desc the binary representation of the key // +arg msg =type Str =desc the message to process // +arg result =type Str =desc the resulting binary string // // //------------------ PROTO ----------------------------------------------------- hmacSha512 +Proto hmacSha512 =type fun Str Str -> Str =mode function =pkg core.crypto.hash =impl mcy =link =desc Computes a sha512 HMAC for a given key and a given string. // +arg key =type Str =desc the binary representation of the key // +arg msg =type Str =desc the message to process // +arg result =type Str =desc the resulting binary string // // //------------------ PROTO ----------------------------------------------------- md5 +Proto md5 =type fun Str -> Str =mode function =pkg core.crypto.hash =impl mcy =link =desc Computes the md5 hash of a given string > hexDump md5 ("foobar") >00000000 38 58 f6 22 30 ac 3c 91 5f 30 0c 66 43 12 c6 3f 8X."0�<�_0.fC..? // +arg msg =type Str =desc the message to hash // +arg result =type Str =desc the resulting binary string // // //------------------ PROTO ----------------------------------------------------- sha1 +Proto sha1 =type fun Str -> Str =mode function =pkg core.crypto.hash =impl mcy =link =desc Computes the sha1 hash of a given string > hexDump sha1 ("foobar") >00000000 88 43 d7 f9 24 16 21 1d e9 eb b9 63 ff 4c e2 81 �C..$.!...�c.L.� >00000010 25 93 28 78 %�(x // +arg msg =type Str =desc the message to hash // +arg result =type Str =desc the resulting binary string // // //------------------ PROTO ----------------------------------------------------- sha512 +Proto sha512 =type fun Str -> Str =mode function =pkg core.crypto.hash =impl mcy =link =desc Computes the sha512 hash of a given string > hexDump sha512 ("foobar") >00000000 0a 50 26 1e bd 1a 39 0f ed 2b f3 26 f2 67 3c 14 .P&.�.9..+.&.g<. >00000010 55 82 a6 34 2d 52 32 04 97 3d 02 19 33 7f 81 61 U��4-R2.�=..3�a >00000020 6a 80 69 b0 12 58 7c f5 63 5f 69 25 f1 b5 6c 36 j�i�.X|.c_i%.�l6 >00000030 02 30 c1 9b 27 35 00 ee 01 3e 03 06 01 bf 24 25 .0.�'5...>...�$% // +arg msg =type Str =desc the message to hash // +arg result =type Str =desc the resulting binary string // // //------------------ PROTO ----------------------------------------------------- sha384 +Proto sha384 =type fun Str -> Str =mode function =pkg core.crypto.hash =impl mcy =link =desc Computes the sha384 hash of a given string > hexDump sha384 ("foobar") >00000000 3c 9c 30 d9 f6 65 e7 4d 51 5c 84 29 60 d4 a4 51 <�0..e.MQ\�)`.�Q >00000010 c8 3a 01 25 fd 3d e7 39 2d 7b 37 23 1a f1 0c 72 .:.%.=.9-{7#...r >00000020 ea 58 ae df cd f8 9a 57 65 bf 90 2a f9 3e cf 06 .X�...�We��*.>.. // +arg msg =type Str =desc the message to hash // +arg result =type Str =desc the resulting binary string // // //------------------ PROTO ----------------------------------------------------- sha256 +Proto sha256 =type fun Str -> Str =mode function =pkg core.crypto.hash =impl mcy =link =desc Computes the sha256 hash of a given string > hexDump sha256 ("foobar") >00000000 c3 ab 8f f1 37 20 e8 ad 90 47 dd 39 46 6b 3c 89 .��.7 .��G.9Fk<� >00000010 74 e5 92 c2 fa 38 3d 4a 39 60 71 4c ae f0 c4 f2 t.�..8=J9`qL�... // +arg msg =type Str =desc the message to hash // +arg result =type Str =desc the resulting binary string // // //------------------ PROTO ----------------------------------------------------- bytesToKey +Proto bytesToKey =type fun Str Str Int -> Str =mode function =pkg core.crypto.hash =impl mcy =link =desc // +arg salt, =type Str =desc // +arg len) =type Str =desc // +arg C =type Int =desc // +arg result =type Str =desc // // //------------------ PROTO ----------------------------------------------------- pbkdf2 +Proto pbkdf2 =type fun a1 Str Int Int (fun a1 Str -> Str) -> Str =mode function =pkg core.crypto.hash =impl mcy =link =desc // +arg salt, =type a1 =desc // +arg count, =type Str =desc // +arg len, =type Int =desc // +arg fHash) =type Int =desc // +arg E =type fun a1 Str -> Str =desc // +arg result =type Str =desc