| 17 | } |
| 18 | |
| 19 | getRandomValues(typedArray: Exclude<TypedArray, Float32Array | Float64Array>) { |
| 20 | if (__ANDROID__) { |
| 21 | if (typedArray.BYTES_PER_ELEMENT !== 1) { |
| 22 | typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset); |
| 23 | } |
| 24 | (<any>org).nativescript.winter_tc.Crypto.getRandomValues(typedArray); |
| 25 | } |
| 26 | if (__IOS__) { |
| 27 | if (typedArray.BYTES_PER_ELEMENT !== 1) { |
| 28 | typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength); |
| 29 | } |
| 30 | const data = NSMutableData.dataWithBytesNoCopyLength(typedArray as never, typedArray.byteLength); |
| 31 | |
| 32 | NSCCrypto.getRandomValues(data); |
| 33 | } |
| 34 | return typedArray; |
| 35 | } |
| 36 | } |