no-brainer-crypto
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

no-brainer-crypto

npm version npm downloads bundle Codecov

Easy no-brainer encryption and hashing for common use cases with built-in best practices.

Usage

Install package:

# npm
npm install no-brainer-crypto

# yarn
yarn add no-brainer-crypto

# pnpm
pnpm install no-brainer-crypto

Import:

// ESM
import {AesService, Pbkdf2Service, ShaService} from "no-brainer-crypto";

// CommonJS
const {AesService, Pbkdf2Service, ShaService} = require("no-brainer-crypto");

const plainText = "text";
const cipherKey = crypto.randomBytes(32);
ßconst password = "password123";

const aes = new AesService(cipherKey, "aes-256-cbc");
const cipherText = aes.encrypt(plainText);
cipherText === aes.decrypt(cipherText) // true

const pbkdf2 = new Pbkdf2Service();
const passwordHash = pbkdf2.hash(password);
pbkdf2.match({plain: password, hash: passwordHash}); // true

const sha = new ShaService("sha256");
const hash = sha.hash(plainText);
sha.match({plain: plainText, hash}); // true

Development

  • Clone this repository
  • Install latest LTS version of Node.js
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Made with 💛

Published under MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i no-brainer-crypto

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

14 kB

Total Files

8

Last publish

Collaborators

  • dsfx3d