Merge pull request #2312 from albert-ziegler/improve_random_number_generation

impove randomness
This commit is contained in:
Hakim El Hattab 2019-02-18 15:14:39 +01:00 committed by GitHub
commit 27b70ed0ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,7 +44,8 @@ app.get("/", function(req, res) {
app.get("/token", function(req,res) { app.get("/token", function(req,res) {
var ts = new Date().getTime(); var ts = new Date().getTime();
var rand = Math.floor(Math.random()*9999999); var rand = new Uint32Array(1);
window.crypto.getRandomValues(rand)
var secret = ts.toString() + rand.toString(); var secret = ts.toString() + rand.toString();
res.send({secret: secret, socketId: createHash(secret)}); res.send({secret: secret, socketId: createHash(secret)});
}); });
@ -61,4 +62,4 @@ var brown = '\033[33m',
green = '\033[32m', green = '\033[32m',
reset = '\033[0m'; reset = '\033[0m';
console.log( brown + "reveal.js:" + reset + " Multiplex running on port " + green + opts.port + reset ); console.log( brown + "reveal.js:" + reset + " Multiplex running on port " + green + opts.port + reset );