node生成uuid


var UUID = require('uuid');

/**
  * 生成激活码
  * UUID.v1 基于时间戳生成(time based)
  * UUID.v4 随机生成(random), 有一定几率重复
  */
  //var ActiCode = UUID.v1();


// Generate a v1 UUID (time-based)
const uuidV1 = require('uuid/v1');
//uuidV1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'
console.log(uuidV1())

// Generate a v4 UUID (random)
const uuidV4 = require('uuid/v4');
uuidV4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'

 

posted @ 2017-10-09 11:20  张书达  阅读(1233)  评论(0编辑  收藏  举报