node/deps/npm/node_modules/unique-slug/index.js
Rebecca Turner 41923c0c07 deps: upgrade npm to 3.3.6
PR-URL: https://github.com/nodejs/node/pull/3310
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-10-22 13:56:09 -04:00

16 lines
443 B
JavaScript

'use strict'
var crypto = require('crypto')
module.exports = function (uniq) {
if (uniq) {
var hash = crypto.createHash('md5')
hash.update(uniq)
return hash.digest('hex')
} else {
// Safe because w/o a callback because this interface can
// neither block nor error (by contrast with randomBytes
// which will throw an exception without enough entropy)
return crypto.pseudoRandomBytes(16).toString('hex')
}
}