(use-modules (hashing sha-2) (rnrs bytevectors) (ice-9 binary-ports) (ice-9 match) (ice-9 time)) (define (port-sha256 port) ;; Return the SHA256 of the data read from PORT. (define bv (make-bytevector 65536)) (define hash (make-sha-256)) (let loop () (match (get-bytevector-n! port bv 0 (bytevector-length bv)) ((? eof-object?) (sha-256-finish! hash) hash) (n (sha-256-update! hash bv 0 n) (loop))))) (define (file-sha256 file) ;; Return the SHA256 of FILE. (call-with-input-file file port-sha256)) (time (pk 'hash (sha-256->string (file-sha256 "/gnu/store/zfp7d4wr5hbl5lrnzs8c15bsc3ygq74g-guile-2.2.6.tar.xz"))))