Skip to content

ppad-tech/base16

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ppad-base16

Fast base16 encoding & decoding on strict ByteStrings.

Usage

A sample GHCi session:

  > :set -XOverloadedStrings
  >
  > -- import qualified
  > import qualified Data.ByteString.Base16 as B16
  >
  > -- simple base16 encoding and decoding
  > B16.encode "hello world"
  "68656c6c6f20776f726c64"
  >
  > B16.decode "68656c6c6f20776f726c64"
  Just "hello world"

Documentation

Haddocks (API documentation, etc.) are hosted at docs.ppad.tech/base16.

Performance

The aim is best-in-class performance. Current benchmark figures on 1kb inputs on an M4 Silicon MacBook Air, where we avail of hardware acceleration via ARM NEON intrinsics, look like (use cabal bench to run the benchmark suite):

  benchmarking ppad-base16/encode
  time                 60.45 ns   (60.29 ns .. 60.65 ns)
                       1.000 R²   (1.000 R² .. 1.000 R²)
  mean                 60.59 ns   (60.42 ns .. 60.78 ns)
  std dev              587.6 ps   (465.2 ps .. 776.7 ps)

  benchmarking ppad-base16/decode
  time                 76.03 ns   (75.93 ns .. 76.15 ns)
                       1.000 R²   (1.000 R² .. 1.000 R²)
  mean                 76.04 ns   (75.94 ns .. 76.16 ns)
  std dev              373.0 ps   (285.3 ps .. 555.3 ps)

You should compile with the 'llvm' flag for maximum performance.

Security

This library aims at the maximum security achievable in a garbage-collected language under an optimizing compiler such as GHC, in which strict constant-timeness can be challenging to achieve.

If you discover any vulnerabilities, please disclose them via security@ppad.tech.

Development

You'll require Nix with flake support enabled. Enter a development shell with:

$ nix develop

Then do e.g.:

$ cabal repl ppad-base16

to get a REPL for the main library.

About

Fast Haskell base16 encoding/decoding

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors