1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/crypto/md5/md5_test.v
MatejMagat305 6bf6a40e0c
crypto: add .free() and .reset() methods to reduce memory leaks with -autofree (#16992)
* Fix unsafe pointer

I was compile vab with '-prod' and it was needed  to fix and it is of course warning

* Add files via upload

* reduce memory  leak s sha512

* add method .free() and .reset() for some
2023-01-16 17:30:40 +02:00

29 lines
970 B
V

// Copyright (c) 2019-2022 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
import crypto.md5
fn test_crypto_md5() {
assert md5.sum('this is a md5 checksum.'.bytes()).hex() == '6fb421ff99036547655984da12973431'
}
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'
}