This repo is forked only for showing implementation of RSA encryption on {N} Nativescript (Since I couldn't find any sample)
npm install jsrsasign
import { KJUR, KEYUTIL } from 'jsrsasign';
const pub = `-----BEGIN PUBLIC KEY-----
CONTENT OF YOUR PUBLIC KEY
-----END PUBLIC KEY-----`;
const prv = `-----BEGIN RSA PRIVATE KEY-----
CONTENT OF YOUR PRIVATE KEY
-----END RSA PRIVATE KEY-----`;
let pvKey = KEYUTIL.getKey(prv,'your passphrase'); // remove passphrase ("your passphrase") if not any
let pbKey = KEYUTIL.getKey(pub);
console.log('encrypted: ' + KJUR.crypto.Cipher.encrypt('YOUR MESSAGE STRING', pbKey, 'RSAOAEP'));
KJUR.crypto.Cipher DOCUMENTATION
console.log('dec: ' + KJUR.crypto.Cipher.decrypt(msg, pvKey, 'RSAOAEP'))
KJUR.crypto.Cipher DOCUMENTATION
The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free cryptography library supporting RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp, CAdES JSON Web Signature/Token/Key in pure JavaScript.
Public page is https://kjur.github.io/jsrsasign .
Your bugfix and pull request contribution are always welcomed :)