1
0
mirror of https://github.com/S2-/securerandomstring.git synced 2025-08-02 10:20:05 +02:00

initial commit

This commit is contained in:
s2
2015-04-22 20:47:04 +02:00
commit 20def6c189
4 changed files with 96 additions and 0 deletions

17
lib/securerandomstring.js Normal file
View File

@@ -0,0 +1,17 @@
var crypto = require('crypto');
function securerandomstring(cb, options) {
options = options || {};
var length = options['length'] || 32;
crypto.randomBytes(length, function(ex, buf) {
if (ex) throw ex;
var string = buf.toString('base64');
cb(string.substr(0, length));
});
};
module.exports = securerandomstring;