README.md (2290B)
1 # base16 2 3 [](https://hackage.haskell.org/package/ppad-base16) 4  5 6 A pure implementation of base16 encoding & decoding on strict 7 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 for pure, highly-auditable Haskell 35 code. We could go slightly faster by direct allocation and writes, but 36 we get pretty close to the best impure versions with only builders. 37 38 Current benchmark figures on 1kb inputs on my mid-2020 MacBook Air look 39 like (use `cabal bench` to run the benchmark suite): 40 41 ``` 42 benchmarking encode/ppad-base16 43 time 5.929 μs (5.847 μs .. 6.013 μs) 44 0.999 R² (0.998 R² .. 0.999 R²) 45 mean 5.975 μs (5.913 μs .. 6.057 μs) 46 std dev 233.1 ns (172.4 ns .. 310.0 ns) 47 48 benchmarking decode/ppad-base16 49 time 4.942 μs (4.884 μs .. 4.995 μs) 50 0.999 R² (0.998 R² .. 0.999 R²) 51 mean 4.908 μs (4.854 μs .. 4.964 μs) 52 std dev 176.8 ns (150.3 ns .. 214.3 ns) 53 variance introduced by outliers: 46% (moderately inflated) 54 ``` 55 56 ## Security 57 58 This library aims at the maximum security achievable in a 59 garbage-collected language under an optimizing compiler such as GHC, in 60 which strict constant-timeness can be challenging to achieve. 61 62 If you discover any vulnerabilities, please disclose them via 63 security@ppad.tech. 64 65 ## Development 66 67 You'll require [Nix][nixos] with [flake][flake] support enabled. Enter a 68 development shell with: 69 70 ``` 71 $ nix develop 72 ``` 73 74 Then do e.g.: 75 76 ``` 77 $ cabal repl ppad-base16 78 ``` 79 80 to get a REPL for the main library. 81 82 [nixos]: https://nixos.org/ 83 [flake]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html