Created
August 12, 2017 17:23
-
-
Save b4284/2682f4022f20f5e3aff3494ea28cd707 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
| 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