about summary refs log tree commit diff
path: root/perl/lib/Nix/Store.xs
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-06-03T13·33+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-06-03T13·33+0200
commit94378910fb55780cc11c1d68045f5c43e269490e (patch)
tree11b77b7e8c456d6e701cbb27cdc8a60b924fad3d /perl/lib/Nix/Store.xs
parenta64da5915d4023d256e1bda425ea6e10c1255812 (diff)
Handle base-16 NarHash fields in signed .narinfo files
Diffstat (limited to 'perl/lib/Nix/Store.xs')
-rw-r--r--perl/lib/Nix/Store.xs11
1 files changed, 11 insertions, 0 deletions
diff --git a/perl/lib/Nix/Store.xs b/perl/lib/Nix/Store.xs
index 6a94bc90b23f..d3bfa19fd846 100644
--- a/perl/lib/Nix/Store.xs
+++ b/perl/lib/Nix/Store.xs
@@ -232,6 +232,17 @@ SV * hashString(char * algo, int base32, char * s)
         }
 
 
+SV * convertHash(char * algo, char * s, int toBase32)
+    PPCODE:
+        try {
+            Hash h = parseHash16or32(parseHashType(algo), s);
+            string s = toBase32 ? printHash32(h) : printHash(h);
+            XPUSHs(sv_2mortal(newSVpv(s.c_str(), 0)));
+        } catch (Error & e) {
+            croak(e.what());
+        }
+
+
 SV * signString(SV * secretKey_, char * msg)
     PPCODE:
         try {