diff --git a/lib/chibi/crypto/sha2.scm b/lib/chibi/crypto/sha2.scm index 2378b0e6..fa5af55f 100644 --- a/lib/chibi/crypto/sha2.scm +++ b/lib/chibi/crypto/sha2.scm @@ -40,7 +40,11 @@ (u32 (arithmetic-shift n (- 32 k))) (arithmetic-shift n (- k)))) -(define hex integer->hex-string) +(define (hex32 num) + (let ((res (make-string 8 #\0)) + (num (integer->hex-string num))) + (string-copy! res (- 8 (string-length num)) num) + res)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -152,8 +156,8 @@ (if (>= n 56) (chunk (+ i n) 0 a b c d e f g h) (string-append - (hex a) (hex b) (hex c) (hex d) - (hex e) (hex f) (hex g) (if full? (hex h) "")))) + (hex32 a) (hex32 b) (hex32 c) (hex32 d) + (hex32 e) (hex32 f) (hex32 g) (if full? (hex32 h) "")))) (else (chunk (+ i 64) pad a b c d e f g h))))) (else