https://github.com/hydrocarbons/krypton
Krypton is a JavaScript class with Symmetric (asynchronous and synchronous) and Asymmetric encryption and decryption methods.
https://github.com/hydrocarbons/krypton
2019 adf aes asymmetric asymmetric-cryptography async asynchronous decryption encryption hydrocarbons javascript krypton nodejs rsa secure symmetric-key-cryptography sync
Last synced: 7 months ago
JSON representation
Krypton is a JavaScript class with Symmetric (asynchronous and synchronous) and Asymmetric encryption and decryption methods.
- Host: GitHub
- URL: https://github.com/hydrocarbons/krypton
- Owner: HydroCarbons
- License: apache-2.0
- Created: 2019-01-11T22:10:57.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-27T07:38:45.000Z (over 6 years ago)
- Last Synced: 2025-01-16T22:20:10.505Z (9 months ago)
- Topics: 2019, adf, aes, asymmetric, asymmetric-cryptography, async, asynchronous, decryption, encryption, hydrocarbons, javascript, krypton, nodejs, rsa, secure, symmetric-key-cryptography, sync
- Language: JavaScript
- Homepage:
- Size: 32.2 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

## Travis CI
[](https://travis-ci.com/HydroCarbons/krypton)# 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
```javascript
const { Krypton } = require("krypton-js")
```
### Create an instance of Krypton and pass encryptionFileName and Password
```javascript
let Krypton = new Krypton(encryptionFileName, Password)
```### Encrypt Synchronous
```javascript
Krypton.encrypt(data)
```### Decrypt Synchronous
```javascript
data = Krypton.decrypt()
```### Encrypt Asynchronous
```javascript
Krypton.encryptAsync(data).then(result=>{ ... })
// Result = { message: "Encrypted!" }
```### Decrypt Asynchronous
```javascript
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
```javascript
encrypted_data = Krypton.encryptWithRSAPrivateKey( client_request, privateKey )
```### B: data decryption with A's public Key
```javascript
decrypted_data = Krypton.decryptWithRSAPublicKey(encrypted_data, pubKey)
```
### B to A, encryption with A's public Key
```javascript
encrypted_data = Krypton.encryptWithRSAPublicKey(server_response, pubKey)
```### A: decryption with A's private Key
```javascript
decrypted_data = Krypton.decryptWithRSAPrivateKey(encrypted_data, privateKey)
```### Generate a public and private RSA key pair
```javascript
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