| 1 | -- md5.lua |
| 2 | -- (you should put this file in any directory of your LUA_PATH) |
| 3 | |
| 4 | |
| 5 | -- change the next line to point to the md5 dynamic library |
| 6 | |
| 7 | -- local path = "/usr/local/lua/lib/libmd5.so" |
| 8 | --local path = "./libmd5.so" |
| 9 | |
| 10 | --assert(loadlib(path, "luaopen_md5"))() |
| 11 | |
| 12 | |
| 13 | -- Returns the md5 hash value as a string of hexadecimal digits |
| 14 | |
| 15 | function md5.sumhexa (k) |
| 16 | k = md5.sum(k) |
| 17 | return (string.gsub(k, ".", function (c) |
| 18 | return string.format("%02x", string.byte(c)) |
| 19 | end)) |
| 20 | end |
| 21 | |
| 22 | return md5 |