lib/random-unique-id.js
function randomUniqueId () {
    // increment count of generated ids
    randomUniqueId.count++
    // get timestamp
    var timestamp = microTimestamp()
    // create unique id
    randomUniqueId.id = crypto.createHash('sha256')
        // process id, microsec timestamp, and counter
        .update(randomUniqueId.processId + randomUniqueId.id + timestamp + randomUniqueId.count)
        // get hash as hex
        .digest('hex')
        // only get 128 bits
        .substring(0, 32)
    // return object with id and timestamp
    return {
        id: randomUniqueId.id,
        timestamp,
    }
}
function randomUniqueId () {
    // increment count of generated ids
    randomUniqueId.count++
    // get timestamp
    var timestamp = microTimestamp()
    // create unique id
    randomUniqueId.id = crypto.createHash('sha256')
        // process id, microsec timestamp, and counter
        .update(randomUniqueId.processId + randomUniqueId.id + timestamp + randomUniqueId.count)
        // get hash as hex
        .digest('hex')
        // only get 128 bits
        .substring(0, 32)
    // return object with id and timestamp
    return {
        id: randomUniqueId.id,
        timestamp,
    }
}
function randomUniqueId ( ) { // increment count of generated ids randomUniqueId . count ++ // get timestamp var timestamp = microTimestamp ( ) // create unique id randomUniqueId . id = crypto . createHash ( 'sha256' ) // process id, microsec timestamp, and counter . update ( randomUniqueId . processId + randomUniqueId . id + timestamp + randomUniqueId . count ) // get hash as hex . digest ( 'hex' ) // only get 128 bits . substring ( 0 , 32 ) // return object with id and timestamp return { id : randomUniqueId . id , timestamp , } }
@function randomUniqueId

generate 128bit hex unique id using true random seed, micro-second timestamp
and counter for entropy.

@returns {object}
@function randomUniqueId