package capnp-rpc-net

  1. Overview
  2. Docs

Source file b64.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
let error fmt =
  fmt |> Fmt.kstr @@ fun msg ->
  Error (`Msg msg)

let encode ~alphabet ~pad s =
  match Base64.encode ~alphabet ~pad s with
  | Ok x -> x
  | Error (`Msg m) -> failwith m    (* Encoding can't really fail *)

let decode ~alphabet ~pad s =
  match Base64.decode ~alphabet ~pad s with
  | Ok _ as x -> x
  | Error (`Msg m) -> Error (`Msg m)  (* Re-add polymorphism *)
  | exception ex -> error "Bad base64 digest %S: %a" s Fmt.exn ex
OCaml

Innovation. Community. Security.