kripta-js
v0.1.5
Published
A tiny asymmetric/symmetric encryption lib for humans.
Downloads
3
Maintainers
Readme
kripta-js
An simple implementation of a Symmetric(AES) and Asymmetric(RSA) encryption for humans.
Features
- Generate RSA keys like
- Encrypt/Decrypt messages, files, binaries on symmetric or asymmetric
How to use
- Install the lib
yarn add kripta-js
# or
npm install kripta-js
To use the symmetric encryption (AES):
Schema :
Code :
import {KriptaAES} from "kripta-js"; const message = "secret-message" const secret_key = "secret-code-password" const k = KriptaAES() // to encrypt const encrypted_msg = k.encrypt(message, secret_key) // to decrypt console.log(k.decrypt(encrypted_msg1, secret_key).decode()) // secret-message
Some methods and their Inputs/Outputs | function | params & types | return type | | ------- | ------- | ------- | | encrypt | message(Buffer|str), secret_key(str) | str | | decrypt | encrypted_messsage(Buffer|str), secret_key(str)| str | | encryptFile | path_of_file(str), password(str) | str | | decryptFile | path_of_encrypted_file(str), password(str) | str |
To use an asymmetric encryption (RSA):
Schema :
Code example:
import {KriptaRSA} from "kripta-js"; const message = "secret-message" const pub_key = `-----BEGIN PUBLIC KEY----- .... -----END PUBLIC KEY-----` const k = KriptaRSA() k.setPublicKey(pub_key) // To encrypt a message const encrypted_msg = k.encrypt(k.getPublicKey(), message.encode()) const priv_key = `-----BEGIN RSA PRIVATE KEY----- ..... -----END RSA PRIVATE KEY-----` k.setPrivateKey(priv_key) // To decrypt console.log(k.decrypt(encrypted_msg).decode()) // secret-message
Some methods and their Inputs/Outputs | function | params & types | return type | | ------- | ------- | ------- | | encrypt | publicKey(str), message(str) | str | | setPublicKey | publicKey(str) | str | | setPrivateKey | privateKey(str) | str | | decrypt | encrypted_messsage(Buffer|str) | str |