UNPKG

@ko-developerhong/react-native-crypto-rsa

Version:
46 lines (45 loc) 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _reactNative = require("react-native"); const LINKING_ERROR = `The package 'react-native-crypto-rsa' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n'; const CryptoRsa = _reactNative.NativeModules.CryptoRsa ? _reactNative.NativeModules.CryptoRsa : new Proxy({}, { get() { throw new Error(LINKING_ERROR); } }); class CryptoRsaClass { instance = CryptoRsa; async init(keySize = 2048) { return await this.instance.generateKeys(keySize); } async getPrivateKey() { return await this.instance.getPrivateKey(); } async getPublicKey() { return await this.instance.getPublicKey(); } async encrypt(message, publicKey) { return await this.instance.encrypt(message, publicKey); } async decrypt(encryptBase64String) { return await this.instance.decrypt(encryptBase64String); } async getSHA512Text(pemString) { return await this.instance.getSHA512Text(pemString); } async base64Decode(base64String) { return await this.instance.base64Decode(base64String); } async base64Encode(message) { return await this.instance.base64Encode(message); } } const RNCryptoRsa = new CryptoRsaClass(); var _default = exports.default = RNCryptoRsa; //# sourceMappingURL=index.js.map