Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.js « unique-slug « node_modules - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 747cf6d06a092219450deee23fdd02c437e0dd98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
'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')
  }
}