diff options
author | Chad Weider <cweider@oofn.net> | 2012-01-28 17:38:23 -0800 |
---|---|---|
committer | Chad Weider <cweider@oofn.net> | 2012-02-10 14:52:34 -0800 |
commit | 363e1685618b1bb05802a221021549eb0ee7a3bd (patch) | |
tree | 2f23e58b4ac2b9459e6f1658792940f5e9fa89ac /node/db/Pad.js | |
parent | 34edba3adfb2c15543273d3de4ddc74abf896e8c (diff) | |
download | etherpad-lite-363e1685618b1bb05802a221021549eb0ee7a3bd.zip |
Share `randomString` method.
This simply shares a common implementation and makes no judgements on the validity of its use. The string created is not a secure random number, so some uses of it may not be applicable.
Diffstat (limited to 'node/db/Pad.js')
-rw-r--r-- | node/db/Pad.js | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/node/db/Pad.js b/node/db/Pad.js index f29f7173..99a53143 100644 --- a/node/db/Pad.js +++ b/node/db/Pad.js @@ -6,6 +6,7 @@ var CommonCode = require('../utils/common_code'); var ERR = require("async-stacktrace"); var Changeset = CommonCode.require("/Changeset"); var AttributePoolFactory = CommonCode.require("/AttributePoolFactory"); +var randomString = CommonCode.require('/pad_utils').randomString; var db = require("./DB").db; var async = require("async"); var settings = require('../utils/Settings'); @@ -478,15 +479,7 @@ function hash(password, salt) function generateSalt() { - var len = 86; - 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; + return randomstring(86); } function compare(hashStr, password) |