No description
Find a file
2025-01-31 06:36:29 -05:00
src Add overloaded Update methods to accept common formats 2025-01-31 06:31:59 -05:00
tests Add overloaded Update methods to accept common formats 2025-01-31 06:31:59 -05:00
LICENSE Add README.md and LICENSE 2025-01-31 06:36:29 -05:00
md4.nimble Add README.md and LICENSE 2025-01-31 06:36:29 -05:00
README.md Add README.md and LICENSE 2025-01-31 06:36:29 -05:00

MD4

This is a pure Nim implementation of MD4. It's mostly useful for compatibility with older MD4-based stuff, like ed2ksum.

The output is an array of 16 bytes. It operates on blocks of 64 bytes, buffering partial blocks as needed.

Disclaimers

  • MD4 is kinda old, and is NOT considered a secure cryptographic hash nowadays.
  • The unpredictability of its output should not be relied upon for security purposes.
  • This library makes no attempt to protect your data against side-channel attacks, or anything else, really.

Example

import md4

# hash a string (also accepts seq and openArray)
var ctx = NewMD4()
ctx.Update("message digest")
let result = ctx.Final()

import std/[sequtils, strutils]
let hexstr = map(result, proc(x: byte): string = toHex(x)).join
assert toLowerAscii(hexstr) == "d9130a8164549fe818874806e1c7014b"

License

MIT. Have fun!