@polkadot/x-randomvalues
Advanced tools
Comparing version 4.0.0-9 to 4.0.0-10
@@ -23,7 +23,7 @@ "use strict"; | ||
for (let i = 0; i < arr.length; i++) { | ||
if ((i & 0x03) === 0) { | ||
if ((i & 0b11) === 0) { | ||
r = Math.random() * 0x100000000; | ||
} | ||
arr[i] = r >>> ((i & 0x03) << 3) & 0xff; | ||
arr[i] = r >>> ((i & 0b11) << 3) & 0xff; | ||
} | ||
@@ -30,0 +30,0 @@ |
{ | ||
"name": "@polkadot/x-randomvalues", | ||
"version": "4.0.0-9", | ||
"version": "4.0.0-10", | ||
"description": "A cross-environment window.crypto.getRandomValues replacement", | ||
@@ -5,0 +5,0 @@ "browser": "browser.js", |
@@ -1,3 +0,3 @@ | ||
declare function getRandomValuesGlobal<T extends Uint8Array>(arr: T): T; | ||
declare const _default: typeof getRandomValuesGlobal; | ||
import insecureRandomValues from './fallback'; | ||
declare const _default: typeof insecureRandomValues; | ||
export default _default; |
@@ -20,5 +20,2 @@ "use strict"; | ||
function getRandomValuesNative(arr) { | ||
// We may want to use a base64 decoder here, but we certainly have an issue where we | ||
// want/need this part as lean as possible. Since Buffer is already needed elsewhere | ||
// (an generally prevalent in JS), we rather use it as-is. | ||
return Buffer.from(_reactNative.NativeModules.RNGetRandomValues.getRandomBase64(arr.length), 'base64').reduce((arr, byte, index) => { | ||
@@ -25,0 +22,0 @@ arr[index] = byte; |
5007
12
90