crypto.md5: fix calculating the same hash values, when .sum() is called several times (#19703)

This commit is contained in:
shove 2023-10-30 15:30:34 +08:00 committed by GitHub
parent 00bf5c4a16
commit 395b55f0cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 6 deletions

View file

@ -167,7 +167,10 @@ pub fn (d &Digest) sum(b_in []u8) []u8 {
return b_out
}
// checksum returns the current byte checksum of the Digest.
// checksum returns the current byte checksum of the Digest,
// it is an internal method and is not recommended because its results are not idempotent.
[deprecated: 'checksum() will be changed to a private method, use sum() instead']
[deprecated_after: '2024-04-30']
pub fn (mut d Digest) checksum() []u8 {
mut len := d.len
// Padding. Add a 1 bit and 0 bits until 56 bytes mod 64.