# Working with hex strings

**URL:** <https://discuss.ocaml.org/t/working-with-hex-strings/2498>\
**Category:** Ecosystem\
**Created:** [August 29, 2018, 9:43pm UTC](https://discuss.ocaml.org/t/working-with-hex-strings/2498 "2018-08-29T21:43:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anuragsoni](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/anuragsoni/32/1107_2.png) [@anuragsoni](https://discuss.ocaml.org/u/anuragsoni)\
**Post date:** [August 29, 2018, 9:43pm UTC](https://discuss.ocaml.org/t/working-with-hex-strings/2498/1 "2018-08-29T21:43:49Z")

</div>

Hello,

I am currently working on [HTTP/2 framing](https://github.com/anuragsoni/h2), and as part of the implementation i’d like to use test data defined at: [https://github.com/http2jp/http2-frame-test-case](https://github.com/http2jp/http2-frame-test-case)

The payload in the test files is defined as a hex string. I was wondering if there is a library or something in the stdlib that can `unhex` the string like: [http://hackage.haskell.org/package/hex-0.1.2/docs/Data-Hex.html](http://hackage.haskell.org/package/hex-0.1.2/docs/Data-Hex.html)

I figured i’d ask before starting to implement my own utility 🙂

Best,  
Anurag

---

<div class="post-metadata">

**Author:** ![igarnier](https://avatars.discourse-cdn.com/v4/letter/i/d78d45/32.png) [@igarnier](https://discuss.ocaml.org/u/igarnier)\
**Post date:** [August 29, 2018, 9:47pm UTC](https://discuss.ocaml.org/t/working-with-hex-strings/2498/2 "2018-08-29T21:47:25Z")

</div>

Hi! Is [https://github.com/mirage/ocaml-hex](https://github.com/mirage/ocaml-hex) what you want?

---

<div class="post-metadata">

**Author:** ![anuragsoni](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/anuragsoni/32/1107_2.png) [@anuragsoni](https://discuss.ocaml.org/u/anuragsoni)\
**Post date:** [August 29, 2018, 10:35pm UTC](https://discuss.ocaml.org/t/working-with-hex-strings/2498/3 "2018-08-29T22:35:17Z")

</div>

Ah thank you! Your answer made me look at the docs again and turns out I just didn’t read it properly 😑

I had missed the fact that it uses polymorphic variant to define the `Hex.t` type.

Initially I had assumed that there wasn’t a way to create a `Hex.t` from a string that was already hexadecimal.
