mirror of
https://github.com/nodejs/node.git
synced 2025-05-21 10:17:17 +00:00

PR-URL: https://github.com/nodejs/node/pull/3310 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
16 lines
443 B
JavaScript
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')
|
|
}
|
|
}
|