lua-users home
lua-l archive

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


On Fri, Oct 29, 2021 at 9:32 AM Scott Morgan <blumf@blueyonder.co.uk> wrote:
(...)
> Thanks. I might try that pure Lua lib and see how it performs (currently
> not sure how I/O bound my app will be)
>
> Was hoping to avoid a 'heavy' dependency like OpenSSL, but that seems to
> be most the libs out there.

You may be interested in
  - Luazen - a C, self-contained crypto library [1]
  - PLC - ("pure Lua crypto") [2]

Luazen doesn't rely on any external library. All the required sources
are included. It offers various crypto and compression algorithms,
including SHA-512, Blake2b the modern Argon2i KDF (key derivation
function), and legacy MD5.

It can be built "a la carte" - See "modular build" in the Readme file.
For example for building luazen with only the functions above, adjust
the FINCS variable in the makefile to:
     FUNCS= -DSHA2 -DBLAKE -DMD5

PLC is a collection of independent Pure Lua implementations of various
hash and encryption algorithms. They are written for Lua 5.3 (and more
recent). It includes various hash functions:
   - SHA2-256, SHA2-512
   - SHA3-256, SHA3-512
   - Blake2b-256 and -512
   - SipHash
   - MD5
   - and common CRC functions (CRC32, Adler32)

Performance is quite good for pure Lua:  For example on a mid-range
laptop with an i5 M430 CPU @ 2.27 GHz, a 10-magabyte string is hashed
in 6.4 sec with SHA2-512 and 9.3 sec with Blake2b-256. (see more
figures at the end of test_perf.lua)

[1] Luazen  https://github.com/philanc/luazen

[2] PLC  https://github.com/philanc/plc

License is MIT for both.

Phil