Skip to content

Latest commit

 

History

History
83 lines (65 loc) · 2.01 KB

README.md

File metadata and controls

83 lines (65 loc) · 2.01 KB

Krypton Icon

Travis CI

Build Status

Krypton

  • Krypton is a JavaScript class with Symmetric (asynchronous and synchronous) and Asymmetric encryption and decryption methods. Cipher is configured to use AES-256-CBC with initialization vector.

Usage

Install

npm install Krypton-js

Require

const { Krypton } = require("krypton-js")

Create an instance of Krypton and pass encryptionFileName and Password

let Krypton = new Krypton(encryptionFileName, Password)

Encrypt Synchronous

Krypton.encrypt(data)

Decrypt Synchronous

data = Krypton.decrypt()

Encrypt Asynchronous

Krypton.encryptAsync(data).then(result=>{ ... })
// Result = { message: "Encrypted!" }

Decrypt Asynchronous

Krypton.decryptAsync(data).then(decryptedData=>{ ... })
//

Asymmetric Encryption/decryption

A exchanges its public key with B

A sends data to B, where encryption of data is done with A's Private Key

encrypted_data = Krypton.encryptWithRSAPrivateKey( client_request, privateKey )

B: data decryption with A's public Key

decrypted_data = Krypton.decryptWithRSAPublicKey(encrypted_data, pubKey)

B to A, encryption with A's public Key

encrypted_data = Krypton.encryptWithRSAPublicKey(server_response, pubKey)

A: decryption with A's private Key

decrypted_data = Krypton.decryptWithRSAPrivateKey(encrypted_data, privateKey)

Generate a public and private RSA key pair

1. ssh-keygen -t rsa
2. openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365

Library Usage/Test

Try it out

npm install

Test

npm run test

Coverage

istanbul cover test

Check coverage folder