@type-ddd/password
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

@type-ddd/password

The @type-ddd/password module provides a class Password for handling password in TypeScript. It includes methods for validating password, encrypt and compare.

Installation

Install rich-domain, @type-ddd/password and bcrypt with your favorite package manager:

npm i rich-domain types-ddd/password bcrypt

#OR 

yarn add rich-domain types-ddd/password bcrypt

Usage

import { Password } from '@type-ddd/password';

// Initialize Password instance with a valid value
const password = Password.init('Y8237FNB@');

// OR

// Create Password instance from provided value
const result = Password.create('Y8237FNB@');

// Or create a strong password
const pass = Password.random();

Compare password

You may compare password with plain text to check if is equal

const password = Password.init('#$89ABC_v');

// check if password is encrypted
password.isEncrypted();
// false

const encrypted = password.encrypt();

// compare
encrypted.compare('#$89ABC_v');
// true

Package Sidebar

Install

npm i @type-ddd/password

Weekly Downloads

24

Version

0.0.3

License

MIT

Unpacked Size

10.4 kB

Total Files

6

Last publish

Collaborators

  • alessandro-dev