Skip to content


Repository files navigation

hashids-ocaml is an OCaml (4.02.3+) implementation of hashids. It generates short, unique, non-sequential ids from numbers, that you can also decode. It is compatible with version 1.0.0 of hashids.

It's licensed under the MIT license. It's available on OPAM. Its documentation and its source code are on GitHub.

Questions? Remarks? Bugs? Want to contribute? Open an issue!

Quick start

Install from OPAM:

$ opam install hashids

Launch utop:

$ utop -require hashids

Create a config:

utop # let config = Hashids.make ();;
val config : Hashids.t = <abstr>

Encode some integers:

utop # Hashids.encode config [42; 57];;
- : string = "wYcGX"

And decode them:

utop # Hashids.decode config "wYcGX";;
- : int list = [42; 57]