Browse files

Use UInt8Array for browser crypto-based RNGs

  • Loading branch information...
1 parent 6e561f8 commit d57c574d32abdaaa984381595fb0640f9c18bb2b @broofa committed Oct 18, 2012
Showing with 2 additions and 6 deletions.
  1. +2 −6 uuid.js
View
8 uuid.js
@@ -25,13 +25,9 @@
// WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto
//
// Moderately fast, high quality
- var _rnds8 = new Array(16), _rnds32 = new Uint32Array(4);
+ var _rnds8 = new Uint8Array(16);
_rng = function whatwgRNG() {
- crypto.getRandomValues(_rnds32);
-
- for (var c = 0 ; c < 16; c++) {
- _rnds8[c] = _rnds32[c >> 2] >>> ((c & 0x03) * 8) & 0xff;
- }
+ crypto.getRandomValues(_rnds8);
return _rnds8;
};
}

0 comments on commit d57c574

Please sign in to comment.