29 lines
708 B
OCaml
29 lines
708 B
OCaml
|
|
let round_trip s =
|
||
|
|
let s' = s |> B32.encode |> B32.decode |> Result.get_ok in
|
||
|
|
match s' = s with
|
||
|
|
| false -> Fmt.failwith "b32 round trip failure: @\nin :`%S`@\nout:`%S`" s' s
|
||
|
|
| true -> ()
|
||
|
|
|
||
|
|
let () =
|
||
|
|
let s = String.init 0xff Char.chr in
|
||
|
|
round_trip s;
|
||
|
|
let s_l = List.init 0x0f (fun i -> String.init i Char.chr) in
|
||
|
|
List.iter round_trip s_l; ()
|
||
|
|
|
||
|
|
let () =
|
||
|
|
let input = "91JPRV3F5GG4EKJNDSJQ8" in
|
||
|
|
let output =
|
||
|
|
input
|
||
|
|
|> B32.decode
|
||
|
|
|> Result.get_ok
|
||
|
|
|> Hash.H64.hash
|
||
|
|
|> Hash.H64.to_octets
|
||
|
|
|> B32.encode
|
||
|
|
in
|
||
|
|
let expected =
|
||
|
|
"D0R24RZ1TPASVQ2NY56CT8AJDYZE9ZGDB0GVZ05E9D4YGZQW2RC5YFPQ0Q86EPW836DY7VYQTNFFJT3ZR2K508F4JVS5JNJKYN2MMFR"
|
||
|
|
in
|
||
|
|
assert (output = expected);
|
||
|
|
|
||
|
|
()
|