From 070873a4fceb7362cb64b7c7b84a929bf4144791 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 3 Jun 2025 22:23:46 +0100 Subject: work/command-line-tool: Add sha1-hash-bytes. * ravanan/work/command-line-tool.scm (sha1-hash-bytes): New public function. (sha1-hash): Use sha1-hash-bytes. --- ravanan/work/command-line-tool.scm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ravanan/work/command-line-tool.scm b/ravanan/work/command-line-tool.scm index d33c80c..0ba735a 100644 --- a/ravanan/work/command-line-tool.scm +++ b/ravanan/work/command-line-tool.scm @@ -39,6 +39,7 @@ formal-parameter-type run-command sha1-hash + sha1-hash-bytes checksum location->path canonicalize-file-value @@ -202,11 +203,14 @@ status in @var{success-codes} as success. Error out otherwise." (with-output-to-port (current-error-port) (cut invoke command)))))) +(define (sha1-hash-bytes file) + "Return the SHA1 hash of @var{file} as a bytevector." + (file-hash (lookup-hash-algorithm 'sha1) + file)) + (define (sha1-hash file) "Return the SHA1 hash of @var{file} as a hexadecimal string." - (bytevector->base16-string - (file-hash (lookup-hash-algorithm 'sha1) - file))) + (bytevector->base16-string (sha1-hash-bytes file))) (define (checksum file) "Return the checksum of @var{file} as defined in the CWL specification." -- cgit v1.2.3