lua-users home
lua-l archive

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


PA wrote:

On Feb 07, 2005, at 11:56, Luiz Henrique de Figueiredo wrote:

Do you really need CRC32?


Yes.

 Doesn't MD5 or SHA1 work for you?


Yes. But for different purposes.

For example, lets assume I want to build an URL pointing to some data of some sort. The data are uniquely identified by a time based UUID:

98ab2edf-ef9c-42e3-a4cc-739442ce2186

A md5 of an uuid is still quite long and obscure:

cfcd208495d565ef66e7dff9f98764da

So... what I would like to do instead is to build an URL which reflects the UUID time, plus a short hash to identity the data in that time frame:

/2005/02/07/12345

Therefore the need for some predictable hashing of some sort. CRC32 comes to mind. But any sort of hashing would do. Doesn't Lua itself have some kind of hashing function for strings?

This'd make me very uneasy - it's too easy to predict CRCs, which may lead to a security flaw later on. A better choice would be to just take the first 6 characters of a SHA1 or similar.