md5

Module for computing MD5 checksums.

See also:

Types

MD5Digest = array[0 .. 15, uint8]
MD5 checksum of a string, obtained with toMD5 proc. Source Edit
MD5Context {...}{.final.} = object
  state: MD5State
  count: array[0 .. 1, uint32]
  buffer: MD5Buffer
Source Edit

Procs

proc toMD5(s: string): MD5Digest {...}{.raises: [], tags: [].}

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"
Source Edit
proc `$`(d: MD5Digest): string {...}{.raises: [], tags: [].}
Converts a MD5Digest value into its string representation. Source Edit
proc getMD5(s: string): string {...}{.raises: [], tags: [].}

Computes an MD5 value of s and returns its string representation. .. note:: available at compile time

See also:

  • toMD5 proc which returns the MD5Digest of a string

Example:

assert getMD5("abc") == "900150983cd24fb0d6963f7d28e17f72"
Source Edit
proc `==`(D1, D2: MD5Digest): bool {...}{.raises: [], tags: [].}
Checks if two MD5Digest values are identical. Source Edit
proc md5Init(c: var MD5Context) {...}{.raises: [], tags: [], gcsafe.}

Initializes a MD5Context.

If you use toMD5 proc there's no need to call this function explicitly.

Source Edit
proc md5Update(c: var MD5Context; input: cstring; len: int) {...}{.raises: [],
    tags: [], gcsafe.}

Updates the MD5Context with the input data of length len.

If you use toMD5 proc there's no need to call this function explicitly.

Source Edit
proc md5Final(c: var MD5Context; digest: var MD5Digest) {...}{.raises: [], tags: [],
    gcsafe.}

Finishes the MD5Context and stores the result in digest.

If you use toMD5 proc there's no need to call this function explicitly.

Source Edit

© 2006–2021 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/md5.html