crypto.sha: fix calculating the same hash values when .sum() is called several times for sha1/256/512 (fix #19696) (#19697)

This commit is contained in:
shove 2023-10-30 09:25:54 +08:00 committed by GitHub
parent 109fc22269
commit ac40981bcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 6 deletions

View file

@ -11,7 +11,9 @@ fn test_crypto_sha1_writer() {
mut digest := sha1.new()
digest.write('This is a'.bytes()) or { assert false }
digest.write(' sha1 checksum.'.bytes()) or { assert false }
sum := digest.sum([])
mut sum := digest.sum([])
assert sum.hex() == 'e100d74442faa5dcd59463b808983c810a8eb5a1'
sum = digest.sum([])
assert sum.hex() == 'e100d74442faa5dcd59463b808983c810a8eb5a1'
}