From 1c04a3874caff49a04a2a7d83c54ed98a45ccaca Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Wed, 1 May 2013 20:26:01 +0100 Subject: [PATCH] Able to load and understand a database --- lib/customUtils.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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;