OCaml bindings for the Yescrypt KDF
  • OCaml 92.2%
  • Makefile 4%
  • Dune 3.8%
Find a file
2026-01-30 11:32:45 +01:00
.github/workflows feat(ci): trigger CI only when specific directories / files change 2026-01-30 11:20:12 +01:00
bin feat(API): add clean and usable scrypt / yescrypt functions 2026-01-25 15:28:14 +01:00
lib fix: resolve C incompatible pointer warning caused by mismatched types 2026-01-26 04:14:38 +01:00
lib_gen fix(ci): use private yescrypt_bindings library name in lib_gen 2026-01-26 01:15:01 +01:00
test feat: add tests for yescrypt function 2026-01-26 12:13:16 +01:00
.gitattributes chore: make dune use the c_lib subtree 2026-01-25 16:02:01 +01:00
.gitignore feat: initial commit 2025-07-30 18:19:03 +02:00
dune-project chore: release v0.1.1 2026-01-26 12:27:12 +01:00
LICENSE docs: add LICENSE and README 2026-01-25 17:41:54 +01:00
Makefile feat: add unit tests 2026-01-25 22:01:52 +01:00
ocaml-yescrypt.opam fix: restore correct dune version in opam file 2026-01-29 01:41:37 +01:00
README.md docs: add opam install instruction 2026-01-29 01:37:44 +01:00

ocaml-yescrypt

What is Yescrypt?

Yescrypt is a scalable, password-hashing function and a key-derivation function (KDF) designed by Alexander Peslyak, also known as Solar Designer, to be highly resistant to hardware-accelerated brute-force attacks. As an evolution of the scrypt algorithm, it introduces enhanced memory-hardness and "strongly sequential" processing, which effectively thwarts large-scale cracking attempts using GPUs, FPGAs, and ASICs.

It has been adopted as the default password-hashing scheme for several major Linux distributions, including Debian, Ubuntu, and Fedora. In these systems, Yescrypt is identifiable in the /etc/shadow file by the $y$ prefix. (Wikipedia)

This library provides a relatively abstract and easy-to-use API for integrating Yescrypt into OCaml programs.

Documentation

You can find the API documentation here.

Installation

Install ocaml-yescrypt via opam:

opam install ocaml-yescrypt

Or pin directly from source:

opam pin add -y git+https://github.com/khalidbelk/ocaml-yescrypt.git

Note: this package needs the libffi-dev and pkg-config system dependencies. The names of those libraries may vary between distros / on MacOS.

Example

Here's a quick example of how to use Yescrypt:

let () =
    let hash = Yescrypt.yescrypt ~passwd:"galaxy2galaxy" ~salt:"hitechjazz"
        ~n:4 ~r:8 ~p:1
    in
    Printf.printf "Result: %s\n" hash

Output:

Result: $y$j25..$cZ4RZB4Oe3aSu/$wE7WgfjiSoHWc95Ob0Z7SdhW9Ygqx3RtqKp8ngTKkL4

License

The C implementations used in this library are based on the work of Colin Percival (scrypt) and Alexander Peslyak (yescrypt).

Additional credit goes to Jeremy Yallop for the Ctypes library used to generate the bindings.

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.