UUID 생성 함수 uuidgen()


24px-Disambig_grey.svg.png 다른 뜻에 대해서는 리눅스 uuidgen 문서를 참조하십시오.

1 Bash[편집]

V1
uuidgen -t
# 260ac300-d225-11e5-906e-00163ed267d5
V4
uuidgen 
# 5335a9b7-8f13-4f93-8eb0-abe724577fb5

2 Cmd[편집]

powershell -Command "[guid]::NewGuid().ToString()"
REM 36080c0a-31e6-443a-af6e-96515a5ae0d5

3 Java[편집]

System.out.println( UUID.randomUUID().toString() );

4 JavaScript[편집]

16px-Crystal_Clear_app_xmag.svg.png JavaScript uuidgen() 문서를 참고하십시오.
function uuidgen() {
  function s4() { return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1); }
  return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}
console.log( uuidgen() );
// 1bc78fba-bff9-2356-1629-ee2414c7b038

5 PHP[편집]

function uuidgen() {
   return sprintf('%08x-%04x-%04x-%04x-%04x%08x',
      mt_rand(0, 0xffffffff),
      mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
      mt_rand(0, 0xffff), mt_rand(0, 0xffffffff)
    );
}
echo uuidgen();
# 2ef6f5ca-30a2-abb3-2355-59c2cdae7740
V4
function uuidgen4() {
   return 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)
    );
}
echo uuidgen4();
# cf00412e-d409-49a2-a4e4-4e6f734b3d86
$uuid = exec('uuidgen');
echo $uuid;
# 59ddcf86-4dcd-4cac-9248-b20efc9bfa97
function uuidgen() { return exec('uuidgen'); }
$uuid = uuidgen();
echo $uuid;
# 30161ed0-4228-4877-8d00-d7c8da503126

6 PowerShell[편집]

[guid]::NewGuid().ToString()
# e9372123-a6a9-422c-adb5-086b9c1e45ad

7 Python[편집]

V1
import uuid
print uuid.uuid1()
# a8098c1a-f86e-11da-bd1a-00112444be1e
V4
import uuid
print uuid.uuid4()
# 16fd2706-8baf-433b-82eb-8c7fada847da

8 SQL[편집]

8.1 MySQL[편집]

V4
SELECT UUID();
# 999627b6-49f3-11e5-b9c9-de311299a4dc

8.2 MSSQL (SQLserver)[편집]

SELECT NEWID();
-- 6E5DE391-488B-4FA8-A43F-878A13565C1B

9 같이 보기[편집]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}