Skip to content
/ neboris Public

A text and buffer encrypt and decrypt module using aes256 and hashed with sha512

License

Notifications You must be signed in to change notification settings

dubfib/neboris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

neboris

NPM version NPM downloads

A package that allows you encrypt and decrypt text and buffers easily, this package uses aes-256-ctr and hashes with sha512 to encrypt and decrypt text and buffers with Initialization Vectors.

Install

This package can be installed with your preferred package manager for Node.js

$ npm install neboris
$ yarn add neboris
$ pnpm add neboris

Benchmark

This package could be a replacement for another package named aes256 and is faster in benchmarks. Bechmarks are ran using the benchmark package. All the benchmark is doing is that it's encrypting and decrypting Hello World! in both text and buffer form using the same key. This benchmark is being ran on a x86_64 GNU/Linux machine.

Package OPS
aes256 20,027
neboris 23,204

Want to test it yourself? Go ahead, you can find the script here. If you do run this script you will need to install the required dependencies with your preferred package manager.

Usage

This package can be used in CommonJS, ESM or Typescript. This package only has one single class Instance that only has two functions which are encrypt and decrypt. The Instance constructor takes one argument which is a string and thats for the key. For both encrypt and decrypt functions they both take one argument that can be either a string or a buffer. In this example the package will encrypt Hello World in both text and buffer form and decrypt it.

const Instance = require('neboris');
const neboris = new Instance('INSERT_KEY_HERE');

const encryptedText = neboris.encrypt('Hello World!');
const decryptedText = neboris.decrypt(encryptedText);
console.log(encryptedText, decryptedText);

const encryptedBuffer = neboris.encrypt(Buffer.from('Hello World!'));
const decryptedBuffer = neboris.decrypt(encryptedBuffer);
console.log(encryptedBuffer, decryptedBuffer);

You can generate a key by using the built in crypto module.

const { randomBytes } = require('crypto');
console.log(randomBytes(32).toString('hex'));

Notice

This package shouldn't be used to encrypt passwords, you should use bcrypt instead.

License

This project is currently under the MIT license.