@@ -208,7 +208,7 @@ pub fn (mut d Digest) write(p_ []u8) !int {
208208pub fn (d &Digest) sum (b_in []u8 ) []u8 {
209209 // Make a copy of d so that caller can keep writing and summing.
210210 mut d0 := d.clone ()
211- hash := d0 .checksum_internal ()
211+ hash := d0 .checksum ()
212212 mut b_out := b_in.clone ()
213213 match d0 .function {
214214 .sha384 {
@@ -235,9 +235,9 @@ pub fn (d &Digest) sum(b_in []u8) []u8 {
235235 return b_out
236236}
237237
238- // TODO:
239- // When the deprecated "checksum()" is finally removed, restore this function name as: "checksum()"
240- fn (mut d Digest) checksum_internal () []u8 {
238+ // checksum returns the current byte checksum of the Digest,
239+ // it is an internal method and is not recommended because its results are not idempotent.
240+ fn (mut d Digest) checksum () []u8 {
241241 // Padding. Add a 1 bit and 0 bits until 112 bytes mod 128.
242242 mut len := d.len
243243 mut tmp := []u8 {len: (128 )}
@@ -269,40 +269,18 @@ fn (mut d Digest) checksum_internal() []u8 {
269269 return digest
270270}
271271
272- // checksum returns the current byte checksum of the Digest,
273- // it is an internal method and is not recommended because its results are not idempotent.
274- @[deprecated: 'checksum() will be changed to a private method, use sum() instead' ]
275- @[deprecated_after: '2024-04-30' ]
276- pub fn (mut d Digest) checksum () []u8 {
277- out := d.checksum_internal ()
278- match d.function {
279- .sha384 {
280- return out[0 ..size384 ]
281- }
282- .sha512_224 {
283- return out[0 ..size224 ]
284- }
285- .sha512_256 {
286- return out[0 ..size256 ]
287- }
288- else {
289- return out
290- }
291- }
292- }
293-
294272// sum512 returns the SHA512 checksum of the data.
295273pub fn sum512 (data []u8 ) []u8 {
296274 mut d := new_digest (.sha512 )
297275 d.write (data) or { panic (err) }
298- return d.checksum_internal ()
276+ return d.checksum ()
299277}
300278
301279// sum384 returns the SHA384 checksum of the data.
302280pub fn sum384 (data []u8 ) []u8 {
303281 mut d := new_digest (.sha384 )
304282 d.write (data) or { panic (err) }
305- sum := d.checksum_internal ()
283+ sum := d.checksum ()
306284 mut sum384 := []u8 {len: size384 }
307285 copy (mut sum384 , sum[..size384 ])
308286 return sum384
@@ -312,7 +290,7 @@ pub fn sum384(data []u8) []u8 {
312290pub fn sum512_224 (data []u8 ) []u8 {
313291 mut d := new_digest (.sha512_224 )
314292 d.write (data) or { panic (err) }
315- sum := d.checksum_internal ()
293+ sum := d.checksum ()
316294 mut sum224 := []u8 {len: size224 }
317295 copy (mut sum224 , sum[..size224 ])
318296 return sum224
@@ -322,7 +300,7 @@ pub fn sum512_224(data []u8) []u8 {
322300pub fn sum512_256 (data []u8 ) []u8 {
323301 mut d := new_digest (.sha512_256 )
324302 d.write (data) or { panic (err) }
325- sum := d.checksum_internal ()
303+ sum := d.checksum ()
326304 mut sum256 := []u8 {len: size256 }
327305 copy (mut sum256 , sum[..size256 ])
328306 return sum256
0 commit comments