base64

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

README.md (2242B)


      1 # ppad-base64
      2 
      3 [![](https://img.shields.io/hackage/v/ppad-base64?color=blue)](https://hackage.haskell.org/package/ppad-base64)
      4 ![](https://img.shields.io/badge/license-MIT-brightgreen)
      5 [![](https://img.shields.io/badge/haddock-base64-lightblue)](https://docs.ppad.tech/base64)
      6 
      7 Fast base64 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.Base64 as B64
     18   >
     19   > -- simple base64 encoding and decoding
     20   > B64.encode "hello world"
     21   "aGVsbG8gd29ybGQ="
     22   >
     23   > B64.decode "aGVsbG8gd29ybGQ="
     24   Just "hello world"
     25 ```
     26 
     27 ## Documentation
     28 
     29 Haddocks (API documentation, etc.) are hosted at
     30 [docs.ppad.tech/base64](https://docs.ppad.tech/base64).
     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-base64/encode
     41   time                 102.0 ns   (101.9 ns .. 102.2 ns)
     42                        1.000 R²   (1.000 R² .. 1.000 R²)
     43   mean                 102.0 ns   (101.9 ns .. 102.1 ns)
     44   std dev              386.6 ps   (313.4 ps .. 521.5 ps)
     45 
     46   benchmarking ppad-base64/decode
     47   time                 160.3 ns   (160.3 ns .. 160.4 ns)
     48                        1.000 R²   (1.000 R² .. 1.000 R²)
     49   mean                 160.3 ns   (160.2 ns .. 160.4 ns)
     50   std dev              242.8 ps   (201.8 ps .. 301.2 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-base64
     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