---
name: "Digest.S"
section: "3o"
platform: "linux"
package: "ocaml"
version: "5.5.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/Digest.S"
---

# Digest.S(3o)

The signature for a hash function that produces digests of length hash\_length from character strings, byte arrays, and files.

## NAME

Digest.S - The signature for a hash function that produces digests of length hash\_length from character strings, byte arrays, and files.

## Module type

Module type   Digest.S

## Documentation

Module type **S**\
  \=  **sig end**

The signature for a hash function that produces digests of length **hash\_length** from character strings, byte arrays, and files.

**Since** 5.2

*type t* =  **string**

The type of digests.

*val hash\_length* :  **int**

The length of digests, in bytes.

*val compare* :  **t -\> t -\> int**

Compare two digests, with the same specification as **compare** .

*val equal* :  **t -\> t -\> bool**

Test two digests for equality.

*val string* :  **string -\> t**

Return the digest of the given string.

*val bytes* :  **bytes -\> t**

Return the digest of the given byte sequence.

*val substring* :  **string -\> int -\> int -\> t**

**substring s ofs len** returns the digest of the substring of  **s** starting at index  **ofs** and containing  **len** characters.

*val subbytes* :  **bytes -\> int -\> int -\> t**

**subbytes s ofs len** returns the digest of the subsequence of  **s** starting at index  **ofs** and containing  **len** bytes.

*val channel* :  **in\_channel -\> int -\> t**

Read characters from the channel and return their digest. See  **Digest.channel** for the full specification.

*val file* :  **string -\> t**

Return the digest of the file whose name is given.

*val output* :  **out\_channel -\> t -\> unit**

Write a digest on the given output channel.

*val input* :  **in\_channel -\> t**

Read a digest from the given input channel.

*val to\_hex* :  **t -\> string**

Return the printable hexadecimal representation of the given digest.

**Raises Invalid\_argument** if the length of the argument is not  **hash\_length** ,

*val of\_hex* :  **string -\> t**

Convert a hexadecimal representation back into the corresponding digest.

**Raises Invalid\_argument** if the length of the argument is not  **2 \* hash\_length** , or if the arguments contains non-hexadecimal characters.
