This commit is contained in:
swrup 2026-02-05 18:08:11 +01:00
parent 5ed9209320
commit 27816979ec

View file

@ -1,10 +1,8 @@
(* TODO hash:
(* TODO
json:
"A JSON object is canonicalized by converting it to an ASCII byte array
with the algorithm specified in RFC 8785. The resulting bytes are
terminated with a single 0-byte and then hashed with SHA512." *)
(* C-terminated strings
some strings need to be hashed with a '\0' termination char *)
open Digestif
@ -38,7 +36,7 @@ module H32 = struct
map (bytes 32) of_octets to_octets
(* hashes are not b32 encoded in the database *)
let caqti : t Caqti_type.t =
let caqti =
let open Caqti_type in
custom
~encode:(fun v -> Ok (to_octets v))
@ -73,7 +71,7 @@ module H64 = struct
map (bytes 64) of_octets to_octets
(* hashes are not b32 encoded in the database *)
let caqti : t Caqti_type.t =
let caqti =
let open Caqti_type in
custom
~encode:(fun v -> Ok (to_octets v))
@ -85,7 +83,8 @@ module H64 = struct
Jsont.of_of_string ~kind:"Hash 64" of_b32 ~enc
end
(* Hash over string + '\0' *)
(* C-terminated strings
some strings need to be hashed with a '\0' termination char *)
module Cstring = struct
module H32 = struct
include H32