https://github.com/ebyte23/asp-guid
Guids for ASP classic JScript
https://github.com/ebyte23/asp-guid
Last synced: 4 months ago
JSON representation
Guids for ASP classic JScript
- Host: GitHub
- URL: https://github.com/ebyte23/asp-guid
- Owner: eByte23
- Created: 2016-08-03T03:42:42.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-03T03:45:21.000Z (almost 10 years ago)
- Last Synced: 2025-07-30T22:24:45.324Z (10 months ago)
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ASP-GUID
Guids for ASP classic JScript based on M$ implmementation https://support.microsoft.com/en-us/kb/320375
```
var Guid = {
New : function(format) {
var format = (format == undefined || String(format) == "undefined" || String(format) == "" || format == null) ? "D" : format;
if (format == "N") {
return this.__formatGuid("");
} else if (format == "D") {
return this.__formatGuid("-");
} else {
return this.__formatGuid("-");
}
},
__formatGuid : function(seperator) {
seperator = (seperator !== undefined && seperator !== "undefined") ? seperator : "-";
return this.__createGUID(8) + seperator +
this.__createGUID(4) + seperator +
this.__createGUID(4) + seperator +
this.__createGUID(4) + seperator +
this.__createGUID(12);
},
__createGUID: function(tmpLength) {
var tmpCounter=0, tmpGUID = "";
var strValid = "ABCDEFGHIJKLM0123456789NOPQRSTUVWXYZ";
for (var tmpCounter = 0; tmpLength > tmpCounter; tmpCounter++) {
tmpGUID += strValid.substr(Math.random() * strValid.length + 1, 1);
}
return tmpGUID;
}
};
```
Usage.
```
Guid.New() | Guid.New("D") returns xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Guid.New("N") returns xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```