@jinx_ark/rsa-crypto-js

1.0.3 • Public • Published

@jinx_ark/rsa-crypto-js

This library provides RSA cryptographic functions. Use this library to encrypt/decrypt the message. Also you can generate private/public key using one of the function.

Installation

Installation is done using the npm install command:

  $ npm install @jinx_ark/rsa-crypto-js

Usage/Examples

To generate key, use the below code:

import { generateKey } from '@jinx_ark/rsa-crypto-js';

generateKey(
    key => {
        setKey(key);
    }, { modulusLength: 2048, hashName: 'SHA-256' }
);
Syntax: generateKey(cb, config)
-------------------------------
config: {
    modulusLength: <it can be 1024, 2048, or 4096>,
    hashName: <it can be "SHA-1", "SHA-256", "SHA-384", or "SHA-512">
}

To encrypt the data, use the below code:

import { encryptRSA } from '@jinx_ark/rsa-crypto-js';

encryptRSA(data => {
    console.log('encrypted data: ', data);
}, config)
Syntax: encryptRSA(cb, config)
------------------------------
config: {
    publicKey: <your generated pubickey>,
    data: <string>
}

To decrypt the data, use the below code:

import { encryptRSA } from '@jinx_ark/rsa-crypto-js';

decryptRSA(data => {
    console.log('encrypted data: :::', data);
    setDecryptedData(data);
}, config)
Syntax: decryptRSA(cb, config)
------------------------------
config: {
    privateKey: <your generated private-key>,
    data: <string>
}

Features

  • Generate private and public key
  • Encrypt/decrypt the data(string)

Authors

Readme

Keywords

none

Package Sidebar

Install

npm i @jinx_ark/rsa-crypto-js

Weekly Downloads

1

Version

1.0.3

License

ISC

Unpacked Size

4.03 kB

Total Files

5

Last publish

Collaborators

  • jinx_ark