Skip to content

Instantly share code, notes, and snippets.

@b4284
Created August 12, 2017 17:23
Show Gist options
  • Select an option

  • Save b4284/2682f4022f20f5e3aff3494ea28cd707 to your computer and use it in GitHub Desktop.

Select an option

Save b4284/2682f4022f20f5e3aff3494ea28cd707 to your computer and use it in GitHub Desktop.
local iter = 0
if #arg < 1 then
error("Input number of iterations")
else
iter = tonumber(arg[1])
end
local rng = io.open("/dev/urandom", "rb")
local sqlite3 = require("lsqlite3")
local db = sqlite3.open("pk_search.db")
function printf(...)
local function wrapper(...) io.write(string.format(...)) end
local status, result = pcall(wrapper, ...)
if not status then error(result, 2) end
end
for i = 1, iter do
printf("iter %d\n", i)
assert(db:exec("begin transaction;") == 0)
for _ = 1, 10000 do
local rnd = rng:read(4)
local csn = string.format("%02X%02X%02X%02X", rnd:byte(1, 4))
local sql = "insert into whitelist (csn) values ('" .. csn .."');"
db:exec(sql)
end
assert(db:exec("commit;") == 0)
end
db:close()
rng:close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment