password-crypt
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

P-CRYPT

Build Status Coverage Status NPM version License Code Size

A Promise-based library build on top of bcrypt/argon2 module with some logic touch to help you hash passwords.

Installation

# npm .
$ npm install password-crypt
# yarn ..
$ yarn add password-crypt

Usage

This is a very basic example of how to use.

// const { PasswordCrypt } = require("password-crypt");
import { PasswordCrypt } from "password-crypt";

// PasswordCrypt instance
// Note: you can pass an config object
const pCrypt = new PasswordCrypt();

// default config object
// {
// secret: 'my-secret',
// algorithm: 'sha512',
// saltSize: 10,
// withArgon: false
// }

// helpers
const hash = (pwd: string) => pCrypt.hash(pwd);
const compare = (pwd: string, hash: string) => pCrypt.compare(pwd, hash);

// also you can pass other configuration by env-vars through process.env
// P_CRYPT_SECRET: same as secret in the config object
// P_CRYPT_ALGORITHM: same as algorithm in the config object
// P_CRYPT_SALT_SIZE: same as saltSize in the config object
// P_CRYPT_WITH_ARGON: same as withArgon in the config object
// ---- secrets used by p-crypt to make the crypt process more complex ---- //
// P_CRYPT_SPECIAL_CHARS
// P_CRYPT_EMOJIS
// P_CRYPT_ARABIC_CHARS
// P_CRYPT_LATINO_CHARS
// P_CRYPT_CHINESE_CHARS
// P_CRYPT_TURKISH_CHARS
// P_CRYPT_SWEDISH_CHARS

You can play around with p-crypt@v2.x on this sandbox codesandbox.io/password-crypt.

License


MIT © Imed Jaberi

Package Sidebar

Install

npm i password-crypt

Weekly Downloads

15

Version

3.0.0

License

MIT

Unpacked Size

33.2 kB

Total Files

6

Last publish

Collaborators

  • 3imed-jaberi