Giter Site home page Giter Site logo

hydrocarbons / krypton Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 33 KB

Krypton is a JavaScript class with Symmetric (asynchronous and synchronous) and Asymmetric encryption and decryption methods.

License: Apache License 2.0

JavaScript 100.00%
krypton secure aes encryption decryption javascript nodejs hydrocarbons adf async

krypton's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.