Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

Commit

Permalink
Use UInt8Array for browser crypto-based RNGs
Browse files Browse the repository at this point in the history
  • Loading branch information
broofa committed Oct 18, 2012
1 parent 6e561f8 commit d57c574
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions uuid.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@
// WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto
// //
// Moderately fast, high quality // Moderately fast, high quality
var _rnds8 = new Array(16), _rnds32 = new Uint32Array(4); var _rnds8 = new Uint8Array(16);
_rng = function whatwgRNG() { _rng = function whatwgRNG() {
crypto.getRandomValues(_rnds32); crypto.getRandomValues(_rnds8);

for (var c = 0 ; c < 16; c++) {
_rnds8[c] = _rnds32[c >> 2] >>> ((c & 0x03) * 8) & 0xff;
}
return _rnds8; return _rnds8;
}; };
} }
Expand Down

0 comments on commit d57c574

Please sign in to comment.