# HG changeset patch # User Waqas Hussain # Date 1244127356 -18000 # Node ID 0a49759464e0432e3197bf51505f9e68d01afdd1 # Parent 2170e2c0d57a4bf4b9e2a14a64f9b0c04c18f2fd util.uuid: Added function seed(string) to allow further seeding of the PRNG diff -r 2170e2c0d57a -r 0a49759464e0 util/uuid.lua --- a/util/uuid.lua Thu Jun 04 18:04:26 2009 +0500 +++ b/util/uuid.lua Thu Jun 04 19:55:56 2009 +0500 @@ -28,10 +28,11 @@ end local buffer = new_random(uniq_time()); +local function _seed(x) + buffer = new_random(buffer..x); +end local function get_nibbles(n) - if #buffer < n then - buffer = new_random(buffer..uniq_time()); - end + if #buffer < n then seed(uniq_time()); end local r = buffer:sub(0, n); buffer = buffer:sub(n+1); return r; @@ -44,5 +45,6 @@ -- generate RFC 4122 complaint UUIDs (version 4 - random) return get_nibbles(8).."-"..get_nibbles(4).."-4"..get_nibbles(3).."-"..(get_twobits())..get_nibbles(3).."-"..get_nibbles(12); end +seed = _seed; return _M;