package cryptokit

  1. Overview
  2. Docs

The Hash module implements unkeyed cryptographic hashes (SHA-1, SHA-256, SHA-512, SHA-3, RIPEMD-160 and MD5), also known as message digest functions. Hash functions used in cryptography are characterized as being <I>one-way</I> (given a hash value, it is computationally infeasible to find a text that hashes to this value) and <I>collision-resistant</I> (it is computationally infeasible to find two different texts that hash to the same value). Thus, the hash of a text can be used as a compact replacement for this text for the purposes of ensuring integrity of the text.

val sha3 : int -> hash

SHA-3, the latest NIST standard for cryptographic hashing, produces hashes of 224, 256, 384 or 512 bits (24, 32, 48 or 64 bytes). The parameter is the desired size of the hash, in bits. It must be one of 224, 256, 384 or 512.

val keccak : int -> hash

SHA-3, the latest NIST standard for cryptographic hashing, produces hashes of 224, 256, 384 or 512 bits (24, 32, 48 or 64 bytes). The parameter is the desired size of the hash, in bits. It must be one of 224, 256, 384 or 512.

The Keccak submission for the SHA-3 is very similar to sha3 but uses a slightly different padding. The parameter is the same as that of sha3.

val sha2 : int -> hash

The Keccak submission for the SHA-3 is very similar to sha3 but uses a slightly different padding. The parameter is the same as that of sha3.

SHA-2, another NIST standard for cryptographic hashing, produces hashes of 224, 256, 384, or 512 bits (24, 32, 48 or 64 bytes). The parameter is the desired size of the hash, in bits. It must be one of 224, 256, 384 or 512.

val sha224 : unit -> hash

SHA-2, another NIST standard for cryptographic hashing, produces hashes of 224, 256, 384, or 512 bits (24, 32, 48 or 64 bytes). The parameter is the desired size of the hash, in bits. It must be one of 224, 256, 384 or 512.

SHA-224 is SHA-2 specialized to 224 bit hashes (24 bytes).

val sha256 : unit -> hash

SHA-224 is SHA-2 specialized to 224 bit hashes (24 bytes).

SHA-256 is SHA-2 specialized to 256 bit hashes (32 bytes).

val sha384 : unit -> hash

SHA-256 is SHA-2 specialized to 256 bit hashes (32 bytes).

SHA-384 is SHA-2 specialized to 384 bit hashes (48 bytes).

val sha512 : unit -> hash

SHA-384 is SHA-2 specialized to 384 bit hashes (48 bytes).

SHA-512 is SHA-2 specialized to 512 bit hashes (64 bytes).

val ripemd160 : unit -> hash

SHA-512 is SHA-2 specialized to 512 bit hashes (64 bytes).

RIPEMD-160 produces 160-bit hashes (20 bytes).

val sha1 : unit -> hash

SHA-1 is the Secure Hash Algorithm revision 1. It is a NIST standard, is widely used, and produces 160-bit hashes (20 bytes). While popular in many legacy applications, it is now known to be insecure. In particular, it is not collision-resistant.

val md5 : unit -> hash

SHA-1 is the Secure Hash Algorithm revision 1. It is a NIST standard, is widely used, and produces 160-bit hashes (20 bytes). While popular in many legacy applications, it is now known to be insecure. In particular, it is not collision-resistant.

MD5 is an older hash function, producing 128-bit hashes (16 bytes). While popular in many legacy applications, it is now known to be insecure. In particular, it is not collision-resistant.

OCaml

Innovation. Community. Security.