26 local function new_random(x) |
26 local function new_random(x) |
27 return sha1(x..os_clock()..tostring({}), true); |
27 return sha1(x..os_clock()..tostring({}), true); |
28 end |
28 end |
29 |
29 |
30 local buffer = new_random(uniq_time()); |
30 local buffer = new_random(uniq_time()); |
|
31 local function _seed(x) |
|
32 buffer = new_random(buffer..x); |
|
33 end |
31 local function get_nibbles(n) |
34 local function get_nibbles(n) |
32 if #buffer < n then |
35 if #buffer < n then seed(uniq_time()); end |
33 buffer = new_random(buffer..uniq_time()); |
|
34 end |
|
35 local r = buffer:sub(0, n); |
36 local r = buffer:sub(0, n); |
36 buffer = buffer:sub(n+1); |
37 buffer = buffer:sub(n+1); |
37 return r; |
38 return r; |
38 end |
39 end |
39 local function get_twobits() |
40 local function get_twobits() |