guid

Javascript生成类GUID随机字符串

帅比萌擦擦* 提交于 2019-12-07 00:22:43
感觉原文对js生成guid理解表述不准确,固改了标题,标题是个人的理解 原文地址是:http://www.cnblogs.com/NoRoad/archive/2010/03/12/1684759.html 方法一: //JS生成类GUID function S4() { return (((1+Math.random())*0x10000)|0).toString(16).substring(1); } function NewGuid() { return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); } 方法二: function newGuid() { var guid = "" ; for ( var i = 1 ; i <= 32 ; i ++ ){ var n = Math.floor(Math.random() * 16.0 ).toString( 16 ); guid += n; if ((i == 8 ) || (i == 12 ) || (i == 16 ) || (i == 20 )) guid += " - " ; } return guid; } 来源: CSDN 作者: DO_DAJIANGJUN 链接: https://blog.csdn.net/XuWei_XuWei

使用js生成GUID的方法

…衆ロ難τιáo~ 提交于 2019-12-07 00:22:30
转载自:https://www.cnblogs.com/kongxiaoshuang/p/6797126.html function GUID () { this .date = new Date (); /* 判断是否初始化过,如果初始化过以下代码,则以下代码将不再执行,实际中只执行一次 */ if ( typeof this .newGUID != 'function' ) { /* 生成GUID码 */ GUID .prototype. newGUID = function () { this .date = new Date (); var guidStr = '' ; sexadecimalDate = this . hexadecimal ( this . getGUIDDate (), 16 ); sexadecimalTime = this . hexadecimal ( this . getGUIDTime (), 16 ); for ( var i = 0 ; i < 9 ; i ++ ) { guidStr += Math . floor ( Math . random () * 16 ). toString ( 16 ); } guidStr += sexadecimalDate; guidStr += sexadecimalTime; while

使用js生成GUID

别等时光非礼了梦想. 提交于 2019-12-07 00:18:06
使用方法: 1、 生成一个新 GUID : var guid = Guid.NewGuid(); 2、 生成一个所有值均为 0 的 GUID : a) var guid = new Guid(); b) var guid = Guid.Empty; 3、 比较两个 GUID 是否相等: g1.Equals(g2); 4、 获取 Guid 的字符串形式。其中, format 为 String 类型的可选参数,其含义为: a) “N” : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx b) “D” 由连字符分隔的 32 位数字 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx c) “B” 括在大括号中、由连字符分隔的 32 位数字: {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} d) “P” 括在圆括号中、由连字符分隔的 32 位数字: (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) 代码如下: // 表示全局唯一标识符 (GUID) 。 function Guid(g){ var arr = new Array(); // 存放 32 位数值的数组 if ( typeof (g) == "string" ){ // 如果构造函数的参数为字符串 InitByString(arr,

JS生成GUID方法

ぐ巨炮叔叔 提交于 2019-12-07 00:17:52
全局唯一标识 (GUID)是一种由算法生成的二进制长度为 128位 的数字标识符,GUID主要用于拥有多个节点,多台计算机的网络或系统中。在理想情况下任何计算几何计算机群都不会生成两个相同的GUID,GUID的总数为 2^128 个,理论上是很难会两个相同。GUID 的格式为“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,其中每个 x 是 0-9 或 a-f 范围内的一个十六进制数。例如:6F9619FF-8B86-D011-B42D-00C04FC964FF 即为有效的 GUID 值。 需要GUID的时候,可以完全由算法自动生成,不需要一个权威机构来管理。 GUID理论上能产生全球唯一的值,对于以后的数据导入很方便。 生成两个相同的GUID的可能性非常小,但不为0,所以生成GUID的短发通常都加入了非随机的参数(如 事件)保证这种重复情况绝对不会发生。 方法一: function GUID() { this.date = new Date(); /* 判断是否初始化过,如果初始化过以下代码,则以下代码将不再执行,实际中只执行一次 */ if (typeof this.newGUID != 'function') { /* 生成GUID码 */ GUID.prototype.newGUID = function () { this.date = new

JavaScript生成GUID的方法

爱⌒轻易说出口 提交于 2019-12-07 00:17:38
GUID全称为全局唯一标识符,也称作 UUID,GUID是一种由算法生成的二进制长度为128位的数字标识符。GUID 的格式为“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”,其中的 x 是 0-9 或 a-f 范围内的一个32位十六进制数。GUID 的总数达到了2^128(3.4×10^38)个,所以随机生成两个相同GUID的可能性非常小,但并不为0。 一、生成GUID的方法一 function guid() { function S4() { return (((1+Math.random())*0x10000)|0).toString(16).substring(1); } return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); } 二、生成GUID的方法二 function guid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); return v.toString(16); }); } 三、生成GUID的方法三 function uuid(

js 生成 guid

。_饼干妹妹 提交于 2019-12-07 00:17:19
GUID(全球唯一标识)是微软使用的一个术语,由一个特定的算法,给某一个实体,如Word文档,创建一个唯一的标识,GUID值就是这个唯一的标识码.除了.Net有专门的方法生成外,JS也可以生成GUID,一般有两种方式,分别是 方法一: //JS生成GUID函数,类似.net中的NewID(); function S4() { return (((1+Math.random())*0x10000)|0).toString(16).substring(1); } function NewGuid() { return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); } 方法二: function newGuid() { var guid = ""; for (var i = 1; i <= 32; i++){ var n = Math.floor(Math.random()*16.0).toString(16); guid += n; if((i==8)||(i==12)||(i==16)||(i==20)) guid += "-"; } return guid; } 由于项目的需要,要在前台生成全球唯一标示,所以在这列出来,以便可以帮助到更多人! http://hi.baidu.com/haofz1983/item

Generate GUID in XSLT

旧巷老猫 提交于 2019-12-06 22:29:29
问题 I need to generate a GUID with XSLT and if needed C#, does anyone know how to best do this? It is to generate unique IDs for HTML items. 回答1: The XSLT generate-id function returns a string that uniquely identifies a node in the document. Note these warnings from the spec: An implementation is under no obligation to generate the same identifiers each time a document is transformed. There is no guarantee that a generated unique identifier will be distinct from any unique IDs specified in the

.NET GUID uppercase string format

跟風遠走 提交于 2019-12-06 20:28:58
问题 I need to format my GUIDs in the dashed format, all uppercase. I know using myGuid.ToString("D") or String.Format("{0:D}", myGuid) gives the dashed format, but using an uppercase D as opposed to a lower-case d doesn't give me an uppercased GUID like I thought it would. Is there a way to do this without doing anything crazy, or do I just need to call myGuid.ToString().ToUpper() ? 回答1: do I just need to call myGuid.ToString().ToUpper() Yep. You could go to the effort of creating a custom

Outputting a GUID in VBScript ignores all text after it

夙愿已清 提交于 2019-12-06 18:28:19
问题 I'm creating a GUID for use in a Classic ASP application, by using TypeLib. However, even a simple test such as writing the GUID out to the screen is giving me problems - it prints the GUID but ignores everything after it (e.g. HTML tags, additional words, anything). Here's the rudimentary code to test this: Set typeLib = Server.CreateObject("Scriptlet.TypeLib") myGuid = typeLib.Guid Response.Write myGuid & " is the new GUID" Set typeLib = Nothing This will display something like {9DDB27D1

Should assembly guid attribute vary for different target framework builds of the same .NET library?

China☆狼群 提交于 2019-12-06 11:54:45
问题 I am developing a .NET library in C# which has to address a wide set of target frameworks. I want to produce a nuget package that would install correctly according to the settings of the target project. In order to achieve that, I am using multiple .csproj files. Each of them is addressing a particular target framework (for example MyLibrary.net45.csproj would create the binaries in bin/*/net45 , MyLibrary.netstandard1.2.csproj would create the output in bin/*/netstandard1.2 , and so on).