13
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Node.jsで汎用一意識別子UUID(RFC 4122)を生成する

Last updated at Posted at 2012-08-25

今日はnode-uuidを試してみます。
https://github.com/broofa/node-uuid

#インストール
npm install node-uuid

#予備知識

参考: rfc4122

参考: UUIDについて

*バージョン1
日時により生成(time-based)
*バージョン4
乱数で生成

あれ?いいのかな。。。ま、いっか。

#どうやって使う?
node-uuidでは、oj.v1()でバージョン1、oj.v4()でバージョン4のUUIDを発生できます。

#do it!

C:\Documents and Settings\hoge>node
> var uuid = require('node-uuid');
> uuid.v1();
'149e6d40-eeaf-11e1-9432-05ef65d4953c'
> uuid.v4();
'e844032f-8ab8-4e7c-94c7-7facb02015a5'
13
13
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?