file/sha1: fix problem with leading zeros
Closes PR 13212
This commit is contained in:
parent
054a52f547
commit
1b4ebef117
|
@ -290,7 +290,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
(sha1-hash-bytes (get-output-bytes p))))
|
||||
|
||||
(define (sha1 in)
|
||||
(format "~x" (sha1-input in)))
|
||||
(bytes->hex-string (hash-value->bytes (sha1-input in))))
|
||||
|
||||
(define (sha1-bytes in)
|
||||
(hash-value->bytes (sha1-input in)))
|
||||
|
|
9
collects/file/tests/sha1.rkt
Normal file
9
collects/file/tests/sha1.rkt
Normal file
|
@ -0,0 +1,9 @@
|
|||
#lang racket/base
|
||||
|
||||
(require file/sha1 rackunit)
|
||||
|
||||
|
||||
;; The docs say that sha1 must return a 40-character string,
|
||||
;; and should include leading zeros.
|
||||
(check-equal? (string-length (sha1 (open-input-string " r a c k et")))
|
||||
40)
|
Loading…
Reference in New Issue
Block a user