Created
May 8, 2018 19:33
-
-
Save catwell/1e022833ae849180adf58d72245ce8e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- If you need pure Lua *and* don't need crypto strength. | |
local function random_keys(n) | |
local t = {} | |
return function() | |
for i = 1, n do t[i] = string.char(math.random(0, 255)) end | |
return table.concat(t) | |
end | |
end | |
local next_key = random_keys(16) | |
local key1 = next_key() | |
local key2 = next_key() | |
--- ... etc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function seq_keys(n) | |
local t = {} | |
for i = 1, n - 1 do t[i] = 0 end | |
t[n] = -1 | |
return function() | |
for i = n, 1, -1 do | |
if t[i] == 255 then | |
t[i] = 0 | |
else | |
t[i] = t[i] + 1 | |
break | |
end | |
end | |
return string.char(table.unpack(t)) | |
end | |
end | |
local next_key = seq_keys(16) | |
local key1 = next_key() | |
local key2 = next_key() | |
--- ... etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment