summaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorRobert Helmer <rhelmer@rhelmer.org>2014-01-15 10:58:50 -0800
committerRobert Helmer <rhelmer@rhelmer.org>2014-01-15 10:58:50 -0800
commit9ef709e7f7145ca4eece6b08f7d5f6fc937acd07 (patch)
treece2bb210bce3fc497a11705082069fbea86b1653 /src/node
parent2f9a9d8695e7c028e596083a7ba8a5dbeaf85b4c (diff)
downloadetherpad-lite-9ef709e7f7145ca4eece6b08f7d5f6fc937acd07.zip
mozilla bug 844796 - use node crypto module for randomString
Diffstat (limited to 'src/node')
-rw-r--r--src/node/utils/randomstring.js13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/node/utils/randomstring.js b/src/node/utils/randomstring.js
index 4c1bba24..4791f274 100644
--- a/src/node/utils/randomstring.js
+++ b/src/node/utils/randomstring.js
@@ -1,16 +1,13 @@
/**
* Generates a random String with the given length. Is needed to generate the Author, Group, readonly, session Ids
*/
+var crypto = require('crypto');
+
var randomString = function randomString(len)
{
- var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
- var randomstring = '';
- for (var i = 0; i < len; i++)
- {
- var rnum = Math.floor(Math.random() * chars.length);
- randomstring += chars.substring(rnum, rnum + 1);
- }
- return randomstring;
+ crypto.randomBytes(48, function(ex, buf) {
+ return buf.toString('hex');
+ });
};
module.exports = randomString;