2023-03-28 23:55:57 +03:00
|
|
|
// Copyright (c) 2019-2023 Alexander Medvednikov. All rights reserved.
|
2019-07-16 15:20:51 +03:00
|
|
|
// Use of this source code is governed by an MIT license
|
|
|
|
// that can be found in the LICENSE file.
|
|
|
|
import crypto.md5
|
|
|
|
|
2021-01-18 15:20:06 +03:00
|
|
|
fn test_crypto_md5() {
|
2019-08-03 08:48:58 +03:00
|
|
|
assert md5.sum('this is a md5 checksum.'.bytes()).hex() == '6fb421ff99036547655984da12973431'
|
2019-07-16 15:20:51 +03:00
|
|
|
}
|
2023-01-16 18:30:40 +03:00
|
|
|
|
|
|
|
fn test_crypto_md5_writer() {
|
|
|
|
mut digest := md5.new()
|
|
|
|
digest.write('this is a'.bytes()) or { assert false }
|
|
|
|
digest.write(' md5 checksum.'.bytes()) or { assert false }
|
|
|
|
sum := digest.sum([])
|
|
|
|
assert sum.hex() == '6fb421ff99036547655984da12973431'
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_crypto_md5_writer_reset() {
|
|
|
|
mut digest := md5.new()
|
|
|
|
digest.write('this is a'.bytes()) or { assert false }
|
|
|
|
digest.write(' md5 checksum.'.bytes()) or { assert false }
|
|
|
|
_ = digest.sum([])
|
|
|
|
digest.reset()
|
|
|
|
digest.write('this is a'.bytes()) or { assert false }
|
|
|
|
digest.write(' md5 checksum.'.bytes()) or { assert false }
|
|
|
|
sum := digest.sum([])
|
|
|
|
assert sum.hex() == '6fb421ff99036547655984da12973431'
|
|
|
|
}
|