Skip to content

Latest commit

 

History

History
executable file
·
61 lines (44 loc) · 2.22 KB

README.md

File metadata and controls

executable file
·
61 lines (44 loc) · 2.22 KB

nativescript-jsrsasign

This repo is forked only for showing implementation of RSA encryption on {N} Nativescript (Since I couldn't find any sample)

Installation

npm install jsrsasign

Usage in {N} Angular

Import Lib in your .ts:

import { KJUR, KEYUTIL } from 'jsrsasign';

Declare Private and Public keys (NOT SECURE - Only for testing purposes):

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-----`;

Import/Convert keys to object:

let pvKey = KEYUTIL.getKey(prv,'your passphrase'); // remove passphrase ("your passphrase") if not any
let pbKey = KEYUTIL.getKey(pub);

KEYUTIL DOCUMENTATION

Encrypt message:

console.log('encrypted: ' + KJUR.crypto.Cipher.encrypt('YOUR MESSAGE STRING', pbKey, 'RSAOAEP'));    

KJUR.crypto.Cipher DOCUMENTATION

Decrypt message:

console.log('dec: ' + KJUR.crypto.Cipher.decrypt(msg, pvKey, 'RSAOAEP'))

KJUR.crypto.Cipher DOCUMENTATION

license bower npm version CDNJS

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 :)