lua-users home
lua-l archive

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

On 5/8/07, Neha <> wrote:
I need to calculate hash of a string in lua.
How would I do this?

Why do you need to compute the hash of a string in Lua?  Lua's table
already provides a hash data structure.

Assuming that you don't want a hash data structure, you might be
asking about a cryptographic hash function, or message digest.  In
this case, there exist several MD5 implementations in Lua, as well as
a binding to the OpenSSL library in LuaCrypto.

If you don't want a cryptographic hash, then what kind of hash do you
want?  I dare say that there are as many hash functions for strings as
there pebbles on a beach.  Well, not quite that many I guess.  Anyway,
check the links from the Wikipedia page:

and of course, Lua hashes strings too: