# \[ANN\] hexen.0.1

**URL:** <https://discuss.ocaml.org/t/ann-hexen-0-1/18627>\
**Category:** Community\
**Created:** [October 21, 2026, 12:10am UTC](https://discuss.ocaml.org/t/ann-hexen-0-1/18627 "2026-10-21T00:10:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dx3mod](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dx3mod/32/6740_2.png) [@dx3mod](https://discuss.ocaml.org/u/dx3mod)\
**Post date:** [October 21, 2026, 12:10am UTC](https://discuss.ocaml.org/t/ann-hexen-0-1/18627/1 "2026-10-21T00:10:20Z")

</div>

Yo!

I needed to decode the hexadecimal substring, so I wrote [Hexen](https://github.com/dx3mod/hexen), yet another library for encoding and decoding hexadecimal byte sequences.

The main goal of this library is to provide a flexible API for encoding and decoding substrings into any destination (bytes or buffers).

### Usage

Hexen provides high-level functions like `encode` and `decode` for quick encoding and decoding of strings or substrings.

```ocaml
Hexen.encode "Hello World";;
(* - : string = "48656c6c6f20576f726c64" *)

Hexen.decode "48656c6c6f20576f726c64";;
(* - : string = "Hello World" *)

```

```ocaml
Hexen.encode_substring "Hello World" 0 5;;
(* - : string = "48656c6c6f" *)

Hexen.decode_substring "48656c6c6f20576f726c64" 0 10;;
(* - : string = "Hello" *)

```

Also, Hexen provides functions to encode and decode strings or substrings directly into existing buffers or bytes.

```ocaml
let buffer = Buffer.create 16 in

Hexen.encode_to_buffer "Hello" buffer;
Hexen.encode_substring_to_buffer "Hello World" 5 6 buffer;

let bytes = Bytes.create 12 in 
Hexen.decode_into (Buffer.contents buffer) 0 bytes 0 22;
Bytes.set bytes 11 '!';

bytes
(* - : bytes = Bytes.of_string "Hello World!" *)

```
