README.md (2124B)
1 # ppad-base16 2 3 A pure implementation of base16 encoding & decoding on strict 4 ByteStrings. 5 6 ## Usage 7 8 A sample GHCi session: 9 10 ``` 11 > :set -XOverloadedStrings 12 > 13 > -- import qualified 14 > import qualified Data.ByteString.Base16 as B16 15 > 16 > -- simple base16 encoding and decoding 17 > B16.encode "hello world" 18 "68656c6c6f20776f726c64" 19 > 20 > B16.decode "68656c6c6f20776f726c64" 21 Just "hello world" 22 ``` 23 24 ## Documentation 25 26 Haddocks (API documentation, etc.) are hosted at 27 [docs.ppad.tech/base16](https://docs.ppad.tech/base16). 28 29 ## Performance 30 31 The aim is best-in-class performance for pure, highly-auditable Haskell 32 code. We could go slightly faster by direct allocation and writes, but 33 we get pretty close to the best impure versions with only builders. 34 35 Current benchmark figures on 1kb inputs on my mid-2020 MacBook Air look 36 like (use `cabal bench` to run the benchmark suite): 37 38 ``` 39 benchmarking encode/ppad-base16 40 time 5.929 μs (5.847 μs .. 6.013 μs) 41 0.999 R² (0.998 R² .. 0.999 R²) 42 mean 5.975 μs (5.913 μs .. 6.057 μs) 43 std dev 233.1 ns (172.4 ns .. 310.0 ns) 44 45 benchmarking decode/ppad-base16 46 time 4.942 μs (4.884 μs .. 4.995 μs) 47 0.999 R² (0.998 R² .. 0.999 R²) 48 mean 4.908 μs (4.854 μs .. 4.964 μs) 49 std dev 176.8 ns (150.3 ns .. 214.3 ns) 50 variance introduced by outliers: 46% (moderately inflated) 51 ``` 52 53 ## Security 54 55 This library aims at the maximum security achievable in a 56 garbage-collected language under an optimizing compiler such as GHC, in 57 which strict constant-timeness can be challenging to achieve. 58 59 If you discover any vulnerabilities, please disclose them via 60 security@ppad.tech. 61 62 ## Development 63 64 You'll require [Nix][nixos] with [flake][flake] support enabled. Enter a 65 development shell with: 66 67 ``` 68 $ nix develop 69 ``` 70 71 Then do e.g.: 72 73 ``` 74 $ cabal repl ppad-base16 75 ``` 76 77 to get a REPL for the main library. 78 79 [nixos]: https://nixos.org/ 80 [flake]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html