aboutsummaryrefslogtreecommitdiffstats
path: root/util/random.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2014-09-23 01:44:16 +0200
committerKim Alvefur <zash@zash.se>2014-09-23 01:44:16 +0200
commit65159ec12ff29eaf2f7f934f6ebb2ecf6a51f30e (patch)
tree1e63192849a869212df2448f814cb37c91b04fe5 /util/random.lua
parent77918edaac029ab1fe1c62ffe5a72e0ed0046065 (diff)
parentb58d3248b78bce1bc07575ab1ff2a6f30324fc28 (diff)
downloadprosody-65159ec12ff29eaf2f7f934f6ebb2ecf6a51f30e.tar.gz
prosody-65159ec12ff29eaf2f7f934f6ebb2ecf6a51f30e.zip
Merge 0.10->trunk
Diffstat (limited to 'util/random.lua')
-rw-r--r--util/random.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/util/random.lua b/util/random.lua
index ed5cdf4b..5938a94f 100644
--- a/util/random.lua
+++ b/util/random.lua
@@ -10,7 +10,7 @@ local tostring = tostring;
local os_time = os.time;
local os_clock = os.clock;
local ceil = math.ceil;
-local sha1 = require "util.hashes".sha1;
+local H = require "util.hashes".sha512;
local last_uniq_time = 0;
local function uniq_time()
@@ -21,7 +21,7 @@ local function uniq_time()
end
local function new_random(x)
- return sha1(x..os_clock()..tostring({}));
+ return H(x..os_clock()..tostring({}));
end
local buffer = new_random(uniq_time());
@@ -31,8 +31,8 @@ local function seed(x)
end
local function bytes(n)
- if #buffer < n then seed(uniq_time()); end
- local r = buffer:sub(0, n);
+ if #buffer < n+4 then seed(uniq_time()); end
+ local r = buffer:sub(1, n);
buffer = buffer:sub(n+1);
return r;
end