Note:
In order to use this module, run 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.
See also
- base64 module for a Base64 encoder and decoder
- std/sha1 module for the SHA-1 checksum algorithm
- std/sha2 module for the SHA-2 checksum algorithm
- std/sha3 module for the SHA-3 checksum algorithm
- hashes module for efficient computations of hash values for diverse Nim types
Types
MD5Context {.final.} = object
MD5Digest = array[0 .. 15, uint8]
- MD5 checksum of a string, obtained with the toMD5 proc.
Procs
proc getMD5(s: string): string {....raises: [], tags: [], forbids: [].}
-
Computes an MD5 value of s and returns its string representation.
See also:
- toMD5 proc which returns the MD5Digest of a string
Example:
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:
- getMD5 proc which returns a string representation of the MD5Digest
- $ proc for converting MD5Digest to string
Example:
assert $toMD5("abc") == "900150983cd24fb0d6963f7d28e17f72"