about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tvix/nix-compat/src/nixhash/mod.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/tvix/nix-compat/src/nixhash/mod.rs b/tvix/nix-compat/src/nixhash/mod.rs
index e148eb72ee..727bf77dc5 100644
--- a/tvix/nix-compat/src/nixhash/mod.rs
+++ b/tvix/nix-compat/src/nixhash/mod.rs
@@ -61,11 +61,7 @@ impl NixHash {
     /// Formats a [NixHash] in the Nix default hash format,
     /// which is the algo, followed by a colon, then the lower hex encoded digest.
     pub fn to_nix_hex_string(&self) -> String {
-        format!(
-            "{}:{}",
-            self.algo(),
-            HEXLOWER.encode(self.digest_as_bytes())
-        )
+        format!("{}:{}", self.algo(), self.to_plain_hex_string())
     }
 
     /// Formats a [NixHash] in the format that's used inside CAHash,
@@ -77,6 +73,11 @@ impl NixHash {
             nixbase32::encode(self.digest_as_bytes())
         )
     }
+
+    /// Returns the digest as a hex string -- without any algorithm prefix.
+    pub fn to_plain_hex_string(&self) -> String {
+        HEXLOWER.encode(self.digest_as_bytes())
+    }
 }
 
 impl TryFrom<(HashAlgo, &[u8])> for NixHash {