① java uuid 和guid 的區別
UUID是一個由4個連字型大小(-)將32個位元組長的字元串分隔後生成的字元串,總共36個位元組長。比如:550e8400-e29b-41d4-a716-446655440000
http://gohands.blogbus.com/logs/147479174.html
GUID 是微軟對UUID這個標準的實現。UUID是由開放軟體基金會(OSF)定義的。UUID還有其它各種實現,不止GUID一種。比如我們這里在Java中用到的。
② 如何自動生成Guid碼
在操作過程中,為了測試往往要插入一些Guid碼,可以利用表格生成Guid碼,操作過程如下:新建一個表格,兩個欄位即可,第一個欄位是int
或者其它均可,第二個類型是uniqueidentifier,允許為空,關鍵是修改下面column
properties中的RowGuid,將No改為Yes,在表中添加第一個欄位,Guid碼在第二個欄位中就自動生成了。
③ 哪位高手能提供個產生GUID的JAVA類
GUID是一個128位長的數字,一般用16進製表示。演算法的核心思想是結合機器的網卡、當地時間、一個隨即數來生成GUID。從理論上講,如果一台機器每秒產生10000000個GUID,則可以保證(概率意義上)3240年不重復。
④ 請問java中能把guid轉換成字元串嗎
我覺得,能做到:非常人能做到,不然怎麼號稱全球唯一標識符呢....他這個演算法可以逆過來
不像md5不可逆;
這個類在util包下,java開源的你想研究查看下吧:
我覺得你能按照它的原始演算法逆過來,你可以直接上天了
你去知乎問問吧,大神都在那裡,或許有所幫助,網路要是問的到,我直播剁吊...
⑤ 怎樣用java生成GUID與UUID
兩種方式生成guid與uuid
需要commlog庫
/**
*@authorAdministrator
*
*
*Window-Preferences-Java-CodeStyle-CodeTemplates
*/
importjava.net.InetAddress;
importjava.net.UnknownHostException;
importjava.security.MessageDigest;
importjava.security.NoSuchAlgorithmException;
importjava.security.SecureRandom;
importjava.util.Random;
{
protectedfinalorg.apache.commons.logging.Loglogger=org.apache.commons.logging.LogFactory
.getLog(getClass());
publicStringvalueBeforeMD5="";
publicStringvalueAfterMD5="";
privatestaticRandommyRand;
;
privatestaticStrings_id;
privatestaticfinalintPAD_BELOW=0x10;
privatestaticfinalintTWO_BYTES=0xFF;
/*
*.
*.Youmight
*
*itwitha"timesincefirstloaded"seedtorecethistime.
*.
*/
static{
mySecureRand=newSecureRandom();
longsecureInitializer=mySecureRand.nextLong();
myRand=newRandom(secureInitializer);
try{
s_id=InetAddress.getLocalHost().toString();
}catch(UnknownHostExceptione){
e.printStackTrace();
}
}
/*
*Defaultconstructor.,
*,highperformance.
*/
publicRandomGUID(){
getRandomGUID(false);
}
/*
*Constructorwithsecurityoption.Settingsecuretrue
*
*strong.
*.
*/
publicRandomGUID(booleansecure){
getRandomGUID(secure);
}
/*
*MethodtogeneratetherandomGUID
*/
privatevoidgetRandomGUID(booleansecure){
MessageDigestmd5=null;
StringBuffersbValueBeforeMD5=newStringBuffer(128);
try{
md5=MessageDigest.getInstance("MD5");
}catch(NoSuchAlgorithmExceptione){
logger.error("Error:"+e);
}
try{
longtime=System.currentTimeMillis();
longrand=0;
if(secure){
rand=mySecureRand.nextLong();
}else{
rand=myRand.nextLong();
}
sbValueBeforeMD5.append(s_id);
sbValueBeforeMD5.append(":");
sbValueBeforeMD5.append(Long.toString(time));
sbValueBeforeMD5.append(":");
sbValueBeforeMD5.append(Long.toString(rand));
valueBeforeMD5=sbValueBeforeMD5.toString();
md5.update(valueBeforeMD5.getBytes());
byte[]array=md5.digest();
StringBuffersb=newStringBuffer(32);
for(intj=0;j<array.length;++j){
intb=array[j]&TWO_BYTES;
if(b<PAD_BELOW)
sb.append('0');
sb.append(Integer.toHexString(b));
}
valueAfterMD5=sb.toString();
}catch(Exceptione){
logger.error("Error:"+e);
}
}
/*
*
*(,etc.)
*Example:C2FEEEAC-CFCD-11D1-8B05-00600806D9B6
*/
publicStringtoString(){
Stringraw=valueAfterMD5.toUpperCase();
StringBuffersb=newStringBuffer(64);
sb.append(raw.substring(0,8));
sb.append("-");
sb.append(raw.substring(8,12));
sb.append("-");
sb.append(raw.substring(12,16));
sb.append("-");
sb.append(raw.substring(16,20));
sb.append("-");
sb.append(raw.substring(20));
returnsb.toString();
}
//
publicstaticvoidmain(Stringargs[]){
for(inti=0;i<100;i++){
RandomGUIDmyGUID=newRandomGUID();
System.out.println("SeedingString="+myGUID.valueBeforeMD5);
System.out.println("rawGUID="+myGUID.valueAfterMD5);
System.out.println("RandomGUID="+myGUID.toString());
}
}
}
同樣
UUIDuuid=UUID.randomUUID();
System.out.println("{"+uuid.toString()+"}");
UUID是指在一台機器上生成的數字,它保證對在同一時空中的所有機器都是唯一的。通常平台會提供生成UUID的API。UUID按照開放軟體基金會(OSF)制定的標准計算,用到了乙太網卡地址、納秒級時間、晶元ID碼和許多可能的數字。由以下幾部分的組合:當前日期和時間(UUID的第一個部分與時間有關,如果你在生成一個UUID之後,過幾秒又生成一個UUID,則第一個部分不同,其餘相同),時鍾序列,全局唯一的IEEE機器識別號(如果有網卡,從網卡獲得,沒有網卡以其他方式獲得),UUID的唯一缺陷在於生成的結果串會比較長。關於UUID這個標准使用最普遍的是微軟的GUID(GlobalsUniqueIdentifiers)。
⑥ java中生成的guid是多少位
一個生成GUID的函數: private string getGUID() { System.Guid guid = new Guid(); guid = Guid.NewGuid(); string str = guid.ToString(); return str; } 隨機生成如下字元串: e92b8e30-a6e5-41f6-a6b9-188230a23dd2 格式說明: System.Guid.NewGuid().ToString(format) 格式說明符 返回值的格式 N 32位: 如: D 由連字元分隔的32位數字: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 如:e92b8e30-a6e5-41f6-a6b9-188230a23dd2 B 括在大括弧中、由連字元分隔的32位數字: {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} 如:{e92b8e30-a6e5-41f6-a6b9-188230a23dd2} P 括在圓括弧中、由連字元分隔的32位數字: (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) 如:(e92b8e30-a6e5-41f6-a6b9-188230a23dd2)
⑦ 怎樣在C#中產生像Java中的GUID呢
C#中產生GUID的函數為 Guid.NewGuid()
產生的GUID樣式為 A5B992AD-BF33-4441-80D4-E0DCD3BFE56A
⑧ Java生成UUID通用唯一識別碼有哪些
UUID含義是通用唯一識別碼 (Unive
sally Unique Identifie
),這 是一個軟體建構的標准,
也是
被開源軟體基金會 (Open Softwa
e Foundation, OSF) 的組織在分布式計算環境 (Dist
i
uted Computing Envi
onment, DCE) 領域的一部份。UUID 的目的,是讓分布式系統中的所有元素,都能有唯一的辨識資訊,而不需要透過中央控制端來做辨識資訊的指定。如此一來,每個人都可以建立不與其它人沖突的 UUID。在這樣的情況下,就不需考慮資料庫建立時的名稱重復問題。目前最廣泛應用的 UUID,即是微軟的 Mic
osoft's Glo
ally Unique Identifie
s (GUIDs),而其他重要的應用,則有 Linux ext2
ext3 檔案系統、LUKS 加密分割區、GNOME、KDE、Mac OS X 等等。
⑨ javascript 怎麼生成guid
全局唯一標識符(GUID,Globally Unique Identifier)也稱作 UUID(Universally Unique IDentifier) 。
GUID是一種由演算法生成的二進制長度為128位的數字標識符。GUID 的格式為「xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx」,其中的 x 是 0-9 或 a-f 范圍內的一個32位十六進制數。在理想情況下,任何計算機和計算機集群都不會生成兩個相同的GUID。
GUID 的總數達到了2^128(3.4×10^38)個,所以隨機生成兩個相同GUID的可能性非常小,但並不為0。GUID一詞有時也專指微軟對UUID標準的實現。
在ITjob.他.們那看到的,還有很多演算法,比如:
function uuid(len, radix) {
var chars = ''.split('');
var uuid = [], i;
radix = radix || chars.length;
if (len) {
// Compact form
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
} else {
// rfc4122, version 4 form
var r;
// rfc4122 requires these characters
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
// Fill in random data. At i==19 set the high bits of clock sequence as
// per rfc4122, sec. 4.1.5
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random()*16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
希望能幫到你吧
⑩ uuid交給資料庫生成還是交給java生成好
UUID含義通用唯識別碼 (Universally Unique Identifier) 軟體建構標准源軟體基金 (Open Software Foundation, OSF) 組織應用布式計算環境 (Distributed Computing Environment, DCE) 領域部 UUID 目讓布式系統所元素都能唯辨識資訊需要透央控制端做辨識資訊指定每都建立與其沖突 UUID情況需考慮資料庫建立名稱重復問題目前廣泛應用 UUID即微軟 Microsoft's Globally Unique Identifiers (GUIDs)其重要應用則 Linux ext二/ext三 檔案系統、LUKS 加密割區、GNOME、KDE、Mac OS X 等等 UUID指台機器數字保證同空所機器都唯通平台提供API // 使用JDK一.5,UUID變件簡單事,JDK實現UUID: java.util.UUID,直接調用即. UUID uuid = UUID.randomUUID(); String s = UUID.randomUUID().toString();//用資料庫主鍵id非錯 //UUID由十六位數字組,表現形式例 //550E吧四00-E二9B-一一D四-A漆一陸-四四陸陸55四四000