var Q = require('q') , crypto = require('crypto'); module.exports = function(bytes) { var q = Q.defer(); crypto.randomBytes(bytes || 8, function(ex, buf) { if ( ex ) { q.reject(ex); } else { q.resolve(buf.toString('hex')); } }); return q.promise; };