aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEstevan Castilho <tevo@riajuu.net>2026-08-13 00:21:41 +0000
committerEstevan Castilho <tevo@riajuu.net>2026-08-23 03:06:53 +0000
commit634625d832873b75b3d9c049db2e95fda31135ae (patch)
treed76e246024bd52eea535053cf16f5d168670ec3d
parentb790c77c5e42a220a8419c69dbea3e392ee60fbe (diff)
downloadRNT-634625d832873b75b3d9c049db2e95fda31135ae.tar.gz
RNT-634625d832873b75b3d9c049db2e95fda31135ae.zip
Make hashes printable readably
Diffstat (limited to '')
-rw-r--r--lib/concepts/Hash.ml2
-rw-r--r--lib/concepts/Hash.mli3
2 files changed, 5 insertions, 0 deletions
diff --git a/lib/concepts/Hash.ml b/lib/concepts/Hash.ml
index aac7428..62c7789 100644
--- a/lib/concepts/Hash.ml
+++ b/lib/concepts/Hash.ml
@@ -18,6 +18,8 @@ let to_raw_string hash = Digestif.SHA256.to_raw_string hash
let of_raw_string str = Digestif.SHA256.of_raw_string str
+let to_hum_string hash = Digestif.SHA256.to_hex hash
+
let hash_equals = Digestif.SHA256.equal
let bytes_of_hash (h : hash) = Bytes.of_string (Digestif.SHA256.to_raw_string h)
diff --git a/lib/concepts/Hash.mli b/lib/concepts/Hash.mli
index 44fb3d0..f40d9aa 100644
--- a/lib/concepts/Hash.mli
+++ b/lib/concepts/Hash.mli
@@ -19,6 +19,9 @@ val to_raw_string : hash -> string
(** given a string containing a representation of a hash (as per `to_raw_string`), return the corresponding hash *)
val of_raw_string : string -> hash
+(** given a hash, return a representation of it as a string suitable for being displayed to humans *)
+val to_hum_string : hash -> string
+
(** compare two hashes lexicographically *)
val compare : hash -> hash -> Ordering.ordering