UNPKG

@nativescript/core

Version:

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

31 lines 1.06 kB
import { SubtleCrypto } from './SubtleCrypto'; const subtle = new SubtleCrypto(); export class Crypto { get subtle() { return subtle; } randomUUID() { if (__ANDROID__) { return org.nativescript.winter_cg.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_cg.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); } } } //# sourceMappingURL=index.js.map