nimble install checksums.Module for computing MD5 checksums.
Be aware that using MD5 for cryptographic purposes is strongly discouraged as it is no longer deemed secure enough even against consumer grade computational resources.
This module also works at compile time and in JavaScript.
MD5Context {.final.} = objectMD5Digest = array[0 .. 15, uint8]
proc `$`(d: MD5Digest): string {....raises: [], tags: [], forbids: [].}MD5Digest value into its string representation. proc `==`(D1, D2: MD5Digest): bool {....raises: [], tags: [], forbids: [].}MD5Digest values are identical. proc getMD5(s: string): string {....raises: [], tags: [], forbids: [].}Computes an MD5 value of s and returns its string representation.
See also:
MD5Digest of a stringExample:
assert getMD5("abc") == "900150983cd24fb0d6963f7d28e17f72" proc md5Final(c: var MD5Context; digest: var MD5Digest) {....raises: [], tags: [],
gcsafe, forbids: [].}proc md5Init(c: var MD5Context) {....raises: [], tags: [], gcsafe, forbids: [].}proc md5Update(c: var MD5Context; input: cstring; len: int) {....raises: [],
tags: [], gcsafe, forbids: [].}Updates the MD5Context with the input data of length len.
If you use the toMD5 proc, there's no need to call this function explicitly.
proc md5Update(c: var MD5Context; input: openArray[uint8]) {....raises: [],
tags: [], gcsafe, forbids: [].}proc toMD5(s: string): MD5Digest {....raises: [], tags: [], forbids: [].}Computes the MD5Digest value for a string s.
See also:
MD5Digest
Example:
assert $toMD5("abc") == "900150983cd24fb0d6963f7d28e17f72"
© 2006–2024 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/md5.html