hex-text: ByteString-Text hexidecimal conversions

[ library, mit, text ] [ Propose Tags ] [ Report a vulnerability ]

Encode a ByteString as a hexidecimal Text value, or decode hexidecimal Text as a ByteString.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.2, 0.1.0.4, 0.1.0.6, 0.1.0.7, 0.1.0.8, 0.1.0.9
Change log changelog.md
Dependencies base (>=4.16 && <4.21), base16-bytestring (>=1.0.2 && <1.1), bytestring (>=0.11.4 && <0.13), text (>=1.2.5 && <1.3 || >=2.0 && <2.2) [details]
License MIT
Copyright 2021 Mission Valley Software LLC
Author Chris Martin
Maintainer Chris Martin, Julie Moronuki
Revised Revision 2 made by AndreasAbel at 2024-05-21T12:14:32Z
Category Text
Home page https://github.com/typeclasses/hex-text
Bug tracker https://github.com/typeclasses/hex-text/issues
Source repo head: git clone https://github.com/typeclasses/hex-text
Uploaded by chris_martin at 2023-06-21T23:33:27Z
Distributions LTSHaskell:0.1.0.9, NixOS:0.1.0.9, Stackage:0.1.0.9
Reverse Dependencies 9 direct, 3 indirect [details]
Downloads 3998 total (42 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-06-22 [all 1 reports]

Readme for hex-text-0.1.0.9

[back to package description]

hex-text

hex-text is a small library for converting between ByteStrings and their representations as hexidecimal numbers encoded as Text.

Motivation

When using Stripe for payments, Stripe sends a signature as a hexidecimal Text value. The cryptonite package can be used to verify the signature, but it requires ByteString values, not Text.

Example usage

A ByteString is a list of bytes. A byte is a number between 0 and 255, represented by the Word8 type. In a fixed-width hexidecimal representation, the lowest byte 0 is represented by the hex string 00, and the greatest byte 255 is represented by the hex string ff. So, for example, the ByteString consisting of bytes [ 1, 2, 3, 253, 254, 255 ] is represented as 010203fdfeff.

λ> import Text.Hex (encodeHex)
λ> import Data.ByteString (pack)

λ> (encodeHex . pack) [1, 2, 3, 253, 254, 255]
"010203fdfeff"