somesocks / lua-lockbox

A collection of cryptographic primitives written in pure Lua
MIT License
357 stars 74 forks source link

Support for Lua 5.1 #23

Closed eestdnt closed 4 years ago

eestdnt commented 4 years ago

Hello,

Is it possible to add support for Lua v5.1 so I can 'luarocks install' for v5.1?

tst2005 commented 4 years ago

The main problem is PUC/Rio Lua 5.1 don't have bitwise support. lockbox do lot of bitwise operation.

I already make a small contrib to catch an available bitwise module, see lockbox.util.bit.

IMHO, the rest of the lockbox code should support Lua 5.1 without problem.

Lua and Luarocks don't have official virtual module name. The depencies is made on specific module (with or without version constraint). It is not possible to setup a dependency on an abstracted bitwise module (to target any of bit or bit32 or bit.numberlua or "another bitwise module").

eestdnt commented 4 years ago

Thank you for the reply. I managed to run it with LuaJIT 2.0.5, just need to copy the lockbox/ folder to the source code directory.

tst2005 commented 4 years ago

You're welcome ;)

nodecentral commented 3 years ago

I managed to run it with LuaJIT 2.0.5, just need to copy the lockbox/ folder to the source code directory.

Hi, I’m looking to use this ‘out of the box’ with a standard Lua install too. Where exactly did you put the lockbox/folder for LuaJIT ? Did you need to do anything else ?

eestdnt commented 3 years ago

Hi @nodecentral , You can put the lockbox/ folder in the same working directory where you start the Lua VM, since require "lockbox" would then find the module in the VM current working directory. Another way, if you use luarocks, is to put lockbox/ folder in your project directory and run luarocks make <path to lockbox rockspec file>, e.g. ./lockbox/rockspecs/lockbox-0.1.0-0.rockspec .

nodecentral commented 3 years ago

Thanks so much for responding,

To avoid the folder option, could I also pick and choose the files I need and then use just those in a in more flat structure ?

For example if I wanted to use base64.lua ; as that module requires the following..

local String = require("string");
local Bit = require("lockbox.util.bit");
local Array = require("lockbox.util.array");
local Stream = require("lockbox.util.stream");

Can I just bring all the dependant module files in, and alter the above to the following flat structure?

local String = require("string");
local Bit = require("bit");
local Array = require("array");
local Stream = require("stream");

Would I also need to add the following to the base64 module and the same for all the others I need too ?

module("base64", package.seeall)
eestdnt commented 3 years ago

Yes, I think you can copy the dependent files to same directory where you call the Lua VM if you want a flat file structure. Those files seem to be already exported as modules, so you only have to use require "array" or require "base64" to import them, no need for module(...), looks like the function is deprecated (http://lua-users.org/wiki/ModulesTutorial).