base16

Fast Haskell base16 encoding/decoding (docs.ppad.tech/base16).
git clone git://git.ppad.tech/base16.git
Log | Files | Refs | README | LICENSE

README.md (2254B)


      1 # ppad-base16
      2 
      3 [![](https://img.shields.io/hackage/v/ppad-base16?color=blue)](https://hackage.haskell.org/package/ppad-base16)
      4 ![](https://img.shields.io/badge/license-MIT-brightgreen)
      5 [![](https://img.shields.io/badge/haddock-base16-lightblue)](https://docs.ppad.tech/base16)
      6 
      7 Fast base16 encoding & decoding on strict ByteStrings.
      8 
      9 ## Usage
     10 
     11 A sample GHCi session:
     12 
     13 ```
     14   > :set -XOverloadedStrings
     15   >
     16   > -- import qualified
     17   > import qualified Data.ByteString.Base16 as B16
     18   >
     19   > -- simple base16 encoding and decoding
     20   > B16.encode "hello world"
     21   "68656c6c6f20776f726c64"
     22   >
     23   > B16.decode "68656c6c6f20776f726c64"
     24   Just "hello world"
     25 ```
     26 
     27 ## Documentation
     28 
     29 Haddocks (API documentation, etc.) are hosted at
     30 [docs.ppad.tech/base16](https://docs.ppad.tech/base16).
     31 
     32 ## Performance
     33 
     34 The aim is best-in-class performance. Current benchmark figures on 1kb
     35 inputs on an M4 Silicon MacBook Air, where we avail of hardware
     36 acceleration via ARM NEON intrinsics, look like (use `cabal bench` to
     37 run the benchmark suite):
     38 
     39 ```
     40   benchmarking ppad-base16/encode
     41   time                 60.45 ns   (60.29 ns .. 60.65 ns)
     42                        1.000 R²   (1.000 R² .. 1.000 R²)
     43   mean                 60.59 ns   (60.42 ns .. 60.78 ns)
     44   std dev              587.6 ps   (465.2 ps .. 776.7 ps)
     45 
     46   benchmarking ppad-base16/decode
     47   time                 76.03 ns   (75.93 ns .. 76.15 ns)
     48                        1.000 R²   (1.000 R² .. 1.000 R²)
     49   mean                 76.04 ns   (75.94 ns .. 76.16 ns)
     50   std dev              373.0 ps   (285.3 ps .. 555.3 ps)
     51 ```
     52 
     53 You should compile with the 'llvm' flag for maximum performance.
     54 
     55 ## Security
     56 
     57 This library aims at the maximum security achievable in a
     58 garbage-collected language under an optimizing compiler such as GHC, in
     59 which strict constant-timeness can be challenging to achieve.
     60 
     61 If you discover any vulnerabilities, please disclose them via
     62 security@ppad.tech.
     63 
     64 ## Development
     65 
     66 You'll require [Nix][nixos] with [flake][flake] support enabled. Enter a
     67 development shell with:
     68 
     69 ```
     70 $ nix develop
     71 ```
     72 
     73 Then do e.g.:
     74 
     75 ```
     76 $ cabal repl ppad-base16
     77 ```
     78 
     79 to get a REPL for the main library.
     80 
     81 [nixos]: https://nixos.org/
     82 [flake]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html