diff --git a/lib/customUtils.js b/lib/customUtils.js index ae65503..3a0b7f3 100644 --- a/lib/customUtils.js +++ b/lib/customUtils.js @@ -1,4 +1,5 @@ var fs = require('fs') + , crypto = require('crypto') ; @@ -19,4 +20,17 @@ function ensureDirectoryExists (dir, cb) { } +/** + * Return a random string of length len + */ +function uid (len) { + return crypto.randomBytes(Math.ceil(len * 3 / 4)) + .toString('base64') + .slice(0, len); +} + +console.log(uid(5)); + + module.exports.ensureDirectoryExists = ensureDirectoryExists; +module.exports.uid = uid;