README.md

LJIT2WinCNG

LuaJIT FFI interface to Windows Crytography Next Generation functions found on Windows in the BCrypt.dll and NCrypt.dll libraries.

CNG is for Windows what OpenSSL is for the rest of the world. CNG is not a single libary, but rather a collection of libraries and technologies that provide support for various cryptography scenarios on the Windows platform.

LJIT2WinCNG is two things. First, it provides the simple FFI based interface to these libraries. This is not much more than providing the raw access to the functions that are found in the various .dll files.

Second, it acts as a 'wrapper' for the functions, providing a much more sane Lua way of accessing things.

Example: Generating Random Bytes

local rngBuff, err = BCrypt.GetRandomBytes(16)

This will generate a buffer of 16 random bytes. the function will return a Lua "string" with the bytes in it, or nil, and an appropriate error.

Basically, all the various bits and pieces are stitched together in these easily called functions. You can choose to access the interfaces at any level from the lowest level access to the underlying system calls, all the way up to using fairly simple functions such as there.