- 浏览: 754914 次
- 性别:
- 来自: 北京
-
文章分类
最新评论
-
梦行Monxin商城系统:
java网上商城与php网上商城比较 -
梦行Monxin商城系统:
java网上商城与php网上商城比较 -
任楚娴:
你好,请问html = nvl(html); 这句中的nvl( ...
java html串转换成文本串 -
u013246812:
,谢拉!
jQuery ui Dialog 讲解参数 -
大宝剑99:
...
前端优化
/*
uuid.js - Version 0.3
JavaScript Class to create a UUID like identifier
Copyright (C) 2006-2008, Erik Giberti (AF-Design), All rights reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
The latest version of this file can be downloaded from
http://www.af-design.com/resources/javascript_uuid.php
HISTORY:
6/5/06 - Initial Release
5/22/08 - Updated code to run faster, removed randrange(min,max) in favor of
a simpler rand(max) function. Reduced overhead by using getTime()
method of date class (suggestion by James Hall).
9/5/08 - Fixed a bug with rand(max) and additional efficiencies pointed out
by Robert Kieffer http://broofa.com/
KNOWN ISSUES:
- Still no way to get MAC address in JavaScript
- Research into other versions of UUID show promising possibilities
(more research needed)
- Documentation needs improvement
*/
// On creation of a UUID object, set it's initial value
function UUID(){
this.id = this.createUUID();
}
// When asked what this Object is, lie and return it's value
UUID.prototype.valueOf = function(){ return this.id; }
UUID.prototype.toString = function(){ return this.id; }
//
// INSTANCE SPECIFIC METHODS
//
UUID.prototype.createUUID = function(){
//
// Loose interpretation of the specification DCE 1.1: Remote Procedure Call
// described at http://www.opengroup.org/onlinepubs/009629399/apdxa.htm#tagtcjh_37
// since JavaScript doesn't allow access to internal systems, the last 48 bits
// of the node section is made up using a series of random numbers (6 octets long).
//
var dg = new Date(1582, 10, 15, 0, 0, 0, 0);
var dc = new Date();
var t = dc.getTime() - dg.getTime();
var tl = UUID.getIntegerBits(t,0,31);
var tm = UUID.getIntegerBits(t,32,47);
var thv = UUID.getIntegerBits(t,48,59) + '1'; // version 1, security version is 2
var csar = UUID.getIntegerBits(UUID.rand(4095),0,7);
var csl = UUID.getIntegerBits(UUID.rand(4095),0,7);
// since detection of anything about the machine/browser is far to buggy,
// include some more random numbers here
// if NIC or an IP can be obtained reliably, that should be put in
// here instead.
var n = UUID.getIntegerBits(UUID.rand(8191),0,7) +
UUID.getIntegerBits(UUID.rand(8191),8,15) +
UUID.getIntegerBits(UUID.rand(8191),0,7) +
UUID.getIntegerBits(UUID.rand(8191),8,15) +
UUID.getIntegerBits(UUID.rand(8191),0,15); // this last number is two octets long
return tl + tm + thv + csar + csl + n;
}
//
// GENERAL METHODS (Not instance specific)
//
// Pull out only certain bits from a very large integer, used to get the time
// code information for the first part of a UUID. Will return zero's if there
// aren't enough bits to shift where it needs to.
UUID.getIntegerBits = function(val,start,end){
var base16 = UUID.returnBase(val,16);
var quadArray = new Array();
var quadString = '';
var i = 0;
for(i=0;i<base16.length;i++){
quadArray.push(base16.substring(i,i+1));
}
for(i=Math.floor(start/4);i<=Math.floor(end/4);i++){
if(!quadArray[i] || quadArray[i] == '') quadString += '0';
else quadString += quadArray[i];
}
return quadString;
}
// Replaced from the original function to leverage the built in methods in
// JavaScript. Thanks to Robert Kieffer for pointing this one out
UUID.returnBase = function(number, base){
return (number).toString(base).toUpperCase();
}
// pick a random number within a range of numbers
// int b rand(int a); where 0 <= b <= a
UUID.rand = function(max){
return Math.floor(Math.random() * (max + 1));
}
// end of UUID class file
/*
for(var i = 0; i < 10; i++){
document.write(new UUID().id);
document.write("<br/>");
}
*/
uuid.js - Version 0.3
JavaScript Class to create a UUID like identifier
Copyright (C) 2006-2008, Erik Giberti (AF-Design), All rights reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
The latest version of this file can be downloaded from
http://www.af-design.com/resources/javascript_uuid.php
HISTORY:
6/5/06 - Initial Release
5/22/08 - Updated code to run faster, removed randrange(min,max) in favor of
a simpler rand(max) function. Reduced overhead by using getTime()
method of date class (suggestion by James Hall).
9/5/08 - Fixed a bug with rand(max) and additional efficiencies pointed out
by Robert Kieffer http://broofa.com/
KNOWN ISSUES:
- Still no way to get MAC address in JavaScript
- Research into other versions of UUID show promising possibilities
(more research needed)
- Documentation needs improvement
*/
// On creation of a UUID object, set it's initial value
function UUID(){
this.id = this.createUUID();
}
// When asked what this Object is, lie and return it's value
UUID.prototype.valueOf = function(){ return this.id; }
UUID.prototype.toString = function(){ return this.id; }
//
// INSTANCE SPECIFIC METHODS
//
UUID.prototype.createUUID = function(){
//
// Loose interpretation of the specification DCE 1.1: Remote Procedure Call
// described at http://www.opengroup.org/onlinepubs/009629399/apdxa.htm#tagtcjh_37
// since JavaScript doesn't allow access to internal systems, the last 48 bits
// of the node section is made up using a series of random numbers (6 octets long).
//
var dg = new Date(1582, 10, 15, 0, 0, 0, 0);
var dc = new Date();
var t = dc.getTime() - dg.getTime();
var tl = UUID.getIntegerBits(t,0,31);
var tm = UUID.getIntegerBits(t,32,47);
var thv = UUID.getIntegerBits(t,48,59) + '1'; // version 1, security version is 2
var csar = UUID.getIntegerBits(UUID.rand(4095),0,7);
var csl = UUID.getIntegerBits(UUID.rand(4095),0,7);
// since detection of anything about the machine/browser is far to buggy,
// include some more random numbers here
// if NIC or an IP can be obtained reliably, that should be put in
// here instead.
var n = UUID.getIntegerBits(UUID.rand(8191),0,7) +
UUID.getIntegerBits(UUID.rand(8191),8,15) +
UUID.getIntegerBits(UUID.rand(8191),0,7) +
UUID.getIntegerBits(UUID.rand(8191),8,15) +
UUID.getIntegerBits(UUID.rand(8191),0,15); // this last number is two octets long
return tl + tm + thv + csar + csl + n;
}
//
// GENERAL METHODS (Not instance specific)
//
// Pull out only certain bits from a very large integer, used to get the time
// code information for the first part of a UUID. Will return zero's if there
// aren't enough bits to shift where it needs to.
UUID.getIntegerBits = function(val,start,end){
var base16 = UUID.returnBase(val,16);
var quadArray = new Array();
var quadString = '';
var i = 0;
for(i=0;i<base16.length;i++){
quadArray.push(base16.substring(i,i+1));
}
for(i=Math.floor(start/4);i<=Math.floor(end/4);i++){
if(!quadArray[i] || quadArray[i] == '') quadString += '0';
else quadString += quadArray[i];
}
return quadString;
}
// Replaced from the original function to leverage the built in methods in
// JavaScript. Thanks to Robert Kieffer for pointing this one out
UUID.returnBase = function(number, base){
return (number).toString(base).toUpperCase();
}
// pick a random number within a range of numbers
// int b rand(int a); where 0 <= b <= a
UUID.rand = function(max){
return Math.floor(Math.random() * (max + 1));
}
// end of UUID class file
/*
for(var i = 0; i < 10; i++){
document.write(new UUID().id);
document.write("<br/>");
}
*/
发表评论
-
Chrome扩展程序-BES Blocker
2020-11-27 08:35 271## 使用说明 - Change the response ... -
全国最新行政区划代码(Tree)json数据以及地理数据
2020-11-11 21:23 391基于阿里提供的地理数据 http://datav.aliyun ... -
百度搜索api
2020-11-07 15:26 748<div class="iteye-blog- ... -
Puppeteer 说明记录
2020-11-06 10:52 658<div class="iteye-blo ... -
文本水印
2019-12-20 17:55 485打开控制台,copy如下代码: (functio ... -
unicode字符集特殊符号对应html/js/css符号
2019-04-24 14:46 809转自: http://www.cnblogs.com/cha ... -
网站灰度支持
2015-01-02 07:22 9201 <style>html {overflo ... -
js 端排序 获取td里边的内容去html串化
2014-09-26 18:12 901<script> function delHtml ... -
ie浏览器下的css expression使用
2014-03-06 16:39 1256针对ie浏览器有些情况下显示效果比较差,所以针对ie ... -
输入框自动填充效果 js
2013-12-28 15:58 6087<!doctype html> ... -
js 屏蔽form的onkeydown onkeyup onkeypress 的13按键
2013-07-11 10:49 1842js 屏蔽form的onkeydown onkeyup on ... -
Cookie path的设置
2013-02-21 10:58 1961cookie path 设置 IE对如下的co ... -
html5 (标签一览)
2012-10-16 19:22 1025html5 标签 按字母顺序排 ... -
一键分享腾讯微博,新浪微博等api(WEB 版)
2012-08-10 09:38 10462腾讯微博分享 <script type=" ... -
DOJO js 基本dom操作
2012-06-20 09:44 4628/** ** 基本的DOM操作只是用到了dojo的核 ... -
原始ajax api 操作
2012-04-12 18:00 1108String.prototype.trim = func ... -
js 动态 添加 删除 tr
2012-04-12 17:27 5772今天给新人出了一道题: dom 和 javascrip ... -
ie8下 vml
2012-04-01 13:51 1692近期在做web流程设计器,在ie7下没有问题,显示出来了,但是 ... -
flex vs html5
2011-12-18 18:09 2175何时使用HTML5,而不是Fl ... -
java毕业设计 计算机毕业设计 软件定制开发
2011-10-01 07:00 86工作室承接各种毕业设计以及软件定制开发。 java毕业设计 ...
相关推荐
常见的JavaScript UUID库有`uuid-js`、`uuid`和`shortid`等。 1. `uuid-js`库:这是一个基于RFC4122标准实现的JavaScript库,提供了V1到V5的所有版本UUID生成方法。其中,V1基于时间戳和MAC地址生成,V4完全是随机...
UUID有五个版本,每个版本有不同的生成算法: - **V1**:基于时间戳和MAC地址。 - **V2**:与V1类似,但加入了POSIX用户ID或组ID。 - **V3**:基于命名空间和MD5散列。 - **V4**:完全随机生成,最常用于JavaScript...
《JavaScript中的UUID生成:深入理解Math.uuid.js》 在JavaScript编程中,UUID(Universally Unique Identifier)是一种广泛应用的全局唯一标识符,它主要用于创建对象的唯一ID,尤其是在分布式环境中。Math.uuid....
如果`uuid.js`不是使用`uuid`库,那么它可能包含了一个自定义的UUID生成算法。这可能涉及使用`Math.random()`生成随机数字,结合当前时间戳和其他因素,以确保生成的字符串的唯一性。 4. **测试与应用**: 在`...
- 无意义性:UUID是随机或基于特定算法生成的,因此它没有直接关联到任何特定的信息,这有助于保护数据隐私。 综上所述,UUID生成器是一个便捷的工具,用于快速、简单地获取UUID,广泛应用于各种IT场景,以保证数据...
提到的GitHub项目`uuidjs/uuid`和`google/uuid`都是开源的JavaScript库,提供了对UUID生成的支持,特别是对版本1、3、4、5的实现。这些库可以方便地在JavaScript应用中生成和操作UUID。`@mole`可能是对某个开发者或...
【Js Snowflake算法详解】 Js Snowflake算法,也称为雪花算法,是一种分布式系统中用于生成全局唯一ID的算法。该算法由Twitter开源,其生成的ID由64位的二进制数字组成,分为以下几个部分: 1. **时间戳**(41位)...
此实现的要点(与许多其他实现相比)是:首先,虽然在内部需要 32/64 位无符号整数算法和 MD5/SHA-1 摘要算法,但此 UUID 实现是完全独立且无依赖的. 其次,此实现围绕Uint8Array 、 Buffer或Array标准类,这种方式...
在编程语言中,UUID的使用非常广泛,例如在Java、Python、JavaScript等语言中都有对应的库或内置支持。在数据库设计中,UUID常用于主键,因为它可以避免在分布式环境中出现主键冲突。在分布式服务和微服务架构中,...
需要注意的是,由于JavaScript的最大整数限制在53位,所以如果要与前端交互,建议调整算法,使得ID不超过53位。例如,使用32位存储秒级时间戳,5位存储机器码,16位存储序列号,这样既能满足JS处理,又能保证足够的...
在JavaScript(JS)中,生成UUID通常用于创建唯一的ID,比如在数据库操作、网页交互或者网络通信中。下面我们将详细讨论如何在JavaScript中生成UUID,以及在实际应用中的价值。 首先,我们来看一下提供的JS代码实例...
1. **JavaScript生成UUID的概念**: UUID是通用唯一识别码(Universally Unique Identifier)的缩写,它是一个128位的值,用于创建唯一标识符。在计算机系统中,UUID常用于生成具有唯一性的标识,如数据库记录、API...
tx充值QB页面的mobile_save接口中的encrypt_msg算法 易语言纯算法腾讯充值页面encrypt_msg算法易语言算法,成品算法tx充值QB页面的mobile_save接口中的encrypt_msg值算法。 本帖学习研究探讨 目标网站地址 ...
版本3的UUID是基于命名空间和MD5散列算法生成的,通过特定的命名策略和算法确保唯一性,同时保留了一定的可预测性。 版本4的UUID是完全随机生成的,提供最纯粹的唯一性,但没有版本3的可追溯性。 版本5的UUID与...
8. **Node.js**: Node.js是JavaScript的服务器端运行环境,它使得JavaScript可以用于构建命令行工具和桌面应用,"zazu-uuid-generator"就依赖于Node.js运行。 9. **软件设计模式**: 这个插件展示了命令行工具如何...
它通过使用自定义的编码算法,将UUID的128位二进制数据转化为一个更短的字符串,同时保持其唯一性。这种短UUID通常比标准UUID短得多,更适合在URL、数据库键或者文件名等场景中使用。 使用shortuuid库非常简单。...
全局唯一标识符(GUID,Globally Unique Identifier)也称作 UUID(Universally Unique IDentifier) 。 GUID是一种由算法生成的二进制长度为128位的数字标识符。GUID 的格式为“xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx...
对于开发者来说,通过阅读源码,可以学习到如何在JavaScript中实现UUID生成算法,以及如何组织和维护一个开源项目。如果项目包括测试用例,还可以了解单元测试和集成测试的方法。 在实际应用中,UUID在Web开发中的...
### JavaScript生成GUID的多种算法详解 #### 一、概述 全局唯一标识符(Global Unique Identifier,简称GUID)或称为通用唯一标识符(Universally Unique Identifier,简称UUID),是一种由算法生成的二进制长度为...