diff options
Diffstat (limited to '')
-rw-r--r-- | module/crypto.scm | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/module/crypto.scm b/module/crypto.scm index 0b18f240..3e468018 100644 --- a/module/crypto.scm +++ b/module/crypto.scm @@ -18,7 +18,10 @@ (define (sha256 msg) (define md (make-bytevector SHA256_DIGEST_LENGTH)) - (define bv (string->utf8 msg)) + (define bv + (cond ((bytevector? msg) msg) + ((string? msg) (string->utf8 msg)) + (else (throw 'value-error "Invalid type")))) (SHA256 ((@ (system foreign) bytevector->pointer) bv) (bytevector-length bv) ((@ (system foreign) bytevector->pointer) md)) |