lua-users home
lua-l archive

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


Sorry if I sound rude over email, but this isn't relevant to my question at all? :(
I don't care about security I just need a way to hash arbitrary lua objects, lua already internally does this and I wonder if it's possible to expose that as a C library function. The other option would be to write a lua function which provides a hash code with the same semantics as the internal hash codes.

On Tue, Apr 27, 2021 at 7:27 PM Philippe Verdy <verdyp@gmail.com> wrote:
Lua tables are using a hashing function. That hashing function is fast, but not intended to be secure (and it has been shown that it is not immune to collisions, that occur easily in easily reproducible cases, causing severe degradation of performances, and possibly can be targetted by DOS attacks (denial of services).

I do think that the default hashing function used by tables should be overridable (notably for tables indexing sensitive data, such as user accounts, or certificates if they are indexed by domain names instead of their own secure hashes which should be already SHA1 at least, or SHA256 now for most PKI providers). And there should be a standard API for security algorithm providers, like in Java or .Net or other languages, and a default security provider implemented in the core, implementing some core algorithms (see those enabled by default in Linux kernels for example; some may of these algorithms, be optional but would be required in Russia and China, they are present in Linux Kernel config, some are required in various web standards or common filesystems).



Le mar. 27 avr. 2021 à 13:59, Marcus Mason <m4gicks@gmail.com> a écrit :
Hello list, I need a way to compute a hash code of a lua object. Other languages like java / c# provide a method like GetHashCode() to do this, and I was wondering if it would be possible to write a function like this for lua using the internal hashing mechanism (as a C library I can require). If not is there a way to implement something that provides similar semantics in pure lua?