aboutsummaryrefslogtreecommitdiff
path: root/module/crypto.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-03-03 02:32:04 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-03-07 22:00:16 +0100
commit7dea1c7799b7d57f56bad3f81389d8a150220c82 (patch)
treeae8528e6480123cfde46dba4557ad016c04a5396 /module/crypto.scm
parentAdd tests for (crypto) module. (diff)
downloadcalp-7dea1c7799b7d57f56bad3f81389d8a150220c82.tar.gz
calp-7dea1c7799b7d57f56bad3f81389d8a150220c82.tar.xz
Rewrote checksum->string.
Lets take full advantage of guile's format.
Diffstat (limited to 'module/crypto.scm')
-rw-r--r--module/crypto.scm10
1 files changed, 3 insertions, 7 deletions
diff --git a/module/crypto.scm b/module/crypto.scm
index 6428f16d..79eaaf89 100644
--- a/module/crypto.scm
+++ b/module/crypto.scm
@@ -28,11 +28,7 @@
((@ (system foreign) bytevector->pointer) md))
md)
-(define (checksum->string md)
- (string-concatenate
- (map (lambda (byte)
- (format #f "~x~x"
- (logand #xF (ash byte -4))
- (logand #xF byte)))
- (bytevector->u8-list md))))
+(define* (checksum->string md #:optional port)
+ ((@ (ice-9 format) format) port
+ "~{~2'0x~}" (bytevector->u8-list md)))