This repository contains high-performance SHA-256 hash implementations for various Lua environments, including:
-
LuaJIT (
sha256/luajit.lua
): Hyperoptimized for LuaJIT using FFI for fast memory access and buffer manipulation.- Fastest run: ~0.0076 seconds (1,315,270 hashes/sec)
- Not compatible with standard Lua or Luau.
-
Luau (
sha256/luau.lua
): Optimized for the Luau runtime (used by Roblox and others).- Fastest run: ~0.066 seconds (151,081 hashes/sec)
- Uses Luau-specific optimizations.
-
Lua 5.4 (
sha256/lua54.lua
): Standard Lua 5.4 implementation.- Fastest run: ~0.0076 seconds (1,315,270 hashes/sec)
- Uses standard Lua 5.4 optimizations.
-
Benchmarks: Use
benchmark.lua
to automatically detect your Lua version and run the appropriate benchmark.
luajit benchmark.lua
luau benchmark.lua
lua benchmark.lua