Pure lua hashing, RIPEMD160 or SHA2?

1.1k Views Asked by At

Are there any implementations of these hashing algorithms in pure lua? I've found a couple for MD5 and SHA1 but none for these two which are the ones I'll be needing for a project. In the interests of portability, I need something in pure lua. Anyone know of anything?

2

There are 2 best solutions below

2
hjpotter92 On

Lua's lmd5 library states: A message digest library for Lua based on OpenSSL. It supports MD2, MD4, MD5, SHA1, SHA2, RIPEMD160, MDC2. Though I have never used it. But there are some libraries listed here. You might one of them useful.

Here's another library which might be what you seek.

0
catwell On

If you use LuaJIT I have written an implementation of SHA256 here but it uses FFI ctypes: https://github.com/catwell/cw-lua/tree/master/sha256

Otherwise there's one here in pure Lua 5.2 which I have not tested: http://lua-users.org/wiki/SecureHashAlgorithm (already cited by Dream Eater).