Skip to content

Commit

Permalink
Faster CryptoRNG.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkistner committed Oct 3, 2023
1 parent f4a6b22 commit 46ea5b1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/rng.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ class CryptoRNG extends RNG {
Uint8List generateInternal() {
final b = Uint8List(16);

for (var i = 0; i < 16; i++) {
b[i] = _secureRandom.nextInt(256);
for (var i = 0; i < 16; i += 4) {
var k = _secureRandom.nextInt(1 << 32);
b[i] = k;
b[i + 1] = k >> 8;
b[i + 2] = k >> 16;
b[i + 3] = k >> 24;
}

return b;
Expand Down

0 comments on commit 46ea5b1

Please sign in to comment.