Skip to content

Commit

Permalink
Use crypto api for uuid generation
Browse files Browse the repository at this point in the history
  • Loading branch information
dgreif committed Aug 14, 2024
1 parent f1a9375 commit d045617
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions target/braintree-1.3.10.js
Original file line number Diff line number Diff line change
Expand Up @@ -3734,7 +3734,7 @@ function isArray(value) {

function generateUUID() { // RFC 4122 v4 (pseudo-random) UUID without hyphens
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (xORy) {
var randomHex = Math.floor(Math.random() * 16);
var randomHex = crypto.getRandomValues(new Uint8Array(1))[0] % 16;
var uuidHex = xORy === 'x' ? randomHex : randomHex & 0x3 | 0x8; // jshint ignore:line
return uuidHex.toString(16);
});
Expand Down Expand Up @@ -4786,7 +4786,7 @@ module.exports = {
// RFC 4122 v4 (pseudo-random) UUID
function generate() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0;
var r = crypto.getRandomValues(new Uint8Array(1))[0] % 16;
var v = c === 'x' ? r : r & 0x3 | 0x8;
return v.toString(16);
});
Expand Down Expand Up @@ -6127,7 +6127,7 @@ module.exports = eventEnum;

function _uuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0;
var r = crypto.getRandomValues(new Uint8Array(1))[0] % 16;
var v = c === 'x' ? r : r & 0x3 | 0x8;
return v.toString(16);
});
Expand Down Expand Up @@ -10773,7 +10773,7 @@ function generateUid() {
var uid = '';

for (i = 0; i < 32; i++) {
r = Math.floor(Math.random() * 16);
r = crypto.getRandomValues(new Uint8Array(1))[0] % 16;
uid += r.toString(16);
}

Expand Down

0 comments on commit d045617

Please sign in to comment.