You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
779 B
35 lines
779 B
2 years ago
|
var randomBytes = require('./randomBytes');
|
||
|
exports = function() {
|
||
|
var b = randomBytes(16);
|
||
|
b[6] = (b[6] & 0x0f) | 0x40;
|
||
|
b[8] = (b[8] & 0x3f) | 0x80;
|
||
|
return (
|
||
|
hexBytes[b[0]] +
|
||
|
hexBytes[b[1]] +
|
||
|
hexBytes[b[2]] +
|
||
|
hexBytes[b[3]] +
|
||
|
'-' +
|
||
|
hexBytes[b[4]] +
|
||
|
hexBytes[b[5]] +
|
||
|
'-' +
|
||
|
hexBytes[b[6]] +
|
||
|
hexBytes[b[7]] +
|
||
|
'-' +
|
||
|
hexBytes[b[8]] +
|
||
|
hexBytes[b[9]] +
|
||
|
'-' +
|
||
|
hexBytes[b[10]] +
|
||
|
hexBytes[b[11]] +
|
||
|
hexBytes[b[12]] +
|
||
|
hexBytes[b[13]] +
|
||
|
hexBytes[b[14]] +
|
||
|
hexBytes[b[15]]
|
||
|
);
|
||
|
};
|
||
|
var hexBytes = [];
|
||
|
for (var i = 0; i < 256; i++) {
|
||
|
hexBytes[i] = (i + 0x100).toString(16).substr(1);
|
||
|
}
|
||
|
|
||
|
module.exports = exports;
|