Need help with md5.lua?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.


MD5 sum in pure Lua, with no C and no external dependencies

231 Stars 115 Forks MIT License 57 Commits 4 Opened issues

Services available

Need anything else?

md5.lua Build Status

This pure-Lua module computes md5 in Lua 5.1, Lua 5.2 and LuaJIT, using native bit-manipulation libraries when available, and falling back to table-based manipulation of integers in 5.1.

It implements md5.sum and md5.sumhex like the kernel project md5 package, but it's done completely in Lua, with no dependencies on other libs or C files.


Simple example:

local md5 = require 'md5'

local md5_as_data = md5.sum(message) -- returns raw bytes local md5_as_hex = md5.sumhexa(message) -- returns a hex string local md5_as_hex2 = md5.tohex(md5_as_data) -- returns the same string as md5_as_hex

Incremental example (for computing md5 of streams, or big files which have to be loaded in chunks - new since 1.1.0):

local m =
m:update('some bytes')
m:update('some more bytes')
return md5.tohex(m:finish())


This is a cleanup of an implementation by Adam Baldwin -

Which in turn was a mix of the bitwise lib, by hanzhao (

abrash_han - at -
), and, by Equi 4 Software.

Lua 5.2 and LuaJIT compatibility by Positive07

A very important fix and the incremental variant by pgimeno


This library, as well as all the previous ones in which is based, is released under the MIT license (See license file for details).


The specs for this library are implemented with busted. In order to run them, install busted and then:

cd path/to/where/the/spec/folder/is


Either copy the file or using luarocks:

luarocks install --server= md5

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.