lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 21/05/2012 15:04, Paco Willers wrote:
I would like to store passwords in my Lua 5.1 application. For example as an MD5 hash.

A hash doesn't allow you to store passwords, it only allows to verify a provided password is identical to the expected one. You can't get back a password that have been hashed.
If your goal is only to check passwords, that's OK.

managed to do that with  luacrypto. I wish to continue my developing on a server which
doesn't have the crypto C library installed which luacrypto depends on, so I cannot use
luacrypto here. Is it possible to do hash encrypting in a Lua-only manner? On the Lua wiki
I saw an article: it is possible with Lua 5.2. Can I switch to Lua 5.2 and still use Lua
modules/libs that are written for Lua 5.1? (luasocket, coxpcall, copas) Any tips are welcome.

Indeed, Lua 5.2 has binary operators allowing to compute MD5 or similar algorithms. Probably slower than a C version, but I suppose you won't check thousands of password per second, so it should be OK.

AFAIK, most Lua libraries with native C code will need to be recompiled for Lua 5.2. I had to do that for lfs, luasocket, lpeg...

Philippe Lhoste
--  (near) Paris -- France
--  --  --  --  --  --  --  --  --  --  --  --  --  --