コメントありがとうございます。 サービス終了した今なら、安く中古が手に入りそ…
UUID(v4)を作成する
JavaScript
var getUuId = function() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c){ var r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8; return v.toString(16); }); };
Perl
my $uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'; 1 while($uuid =~ s/x/[split m!!, "0123456789ABCDEF"]->[int(rand 16)]/e); 1 while($uuid =~ s/y/[split m!!, "89AB"]->[int(rand 4)]/e);
PHP
$uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x' ,mt_rand(0, 0xffff) ,mt_rand(0, 0xffff) ,mt_rand(0, 0xffff) ,mt_rand(0, 0x0fff) | 0x4000 ,mt_rand(0, 0x3fff) | 0x8000 ,mt_rand(0, 0xffff) ,mt_rand(0, 0xffff) ,mt_rand(0, 0xffff) );
検索
コメントを残す