kikito / md5.lua

MD5 sum in pure Lua, with no C and no external dependencies
MIT License
326 stars 151 forks source link

format with %08x not handling numbers greater than 32bit int #20

Open xavifr opened 1 year ago

xavifr commented 1 year ago

I have a device (aarch64 cortex-a53) running OpenWRT and lua 5.1.5

Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio (double int32)

When using the md5 library to hash a message I got the following error

usr/bin/lua: ./md5.lua:416: bad argument #3 to 'format' (integer expected, got number)
stack traceback:
       [C]: in function 'format'
       ./md5.lua:416: in function 'tohex'

Changing format() from %08x with 4 bits to %04x with 2 bits fixed the execution