UNPKG

@nativescript/core

Version:

A JavaScript library providing an easy to use api for interacting with iOS and Android platform APIs.

32 lines 1.08 kB
import { SubtleCrypto } from './SubtleCrypto'; const subtle = new SubtleCrypto(); export class Crypto { get subtle() { return subtle; } randomUUID() { if (__ANDROID__) { return org.nativescript.winter_tc.Crypto.randomUUID(); } if (__IOS__) { return NSCCrypto.randomUUID(); } } getRandomValues(typedArray) { if (__ANDROID__) { if (typedArray.BYTES_PER_ELEMENT !== 1) { typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset); } org.nativescript.winter_tc.Crypto.getRandomValues(typedArray); } if (__IOS__) { if (typedArray.BYTES_PER_ELEMENT !== 1) { typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength); } const data = NSMutableData.dataWithBytesNoCopyLength(typedArray, typedArray.byteLength); NSCCrypto.getRandomValues(data); } return typedArray; } } //# sourceMappingURL=index.js.map