@eternaljs/password-generator
v2.0.1
Published
A random password generator helps create strong passwords to enhance security, while AES encryption is a robust algorithm used to secure data by transforming it into ciphertext, rendering it unreadable without the appropriate decryption key.
Downloads
24
Maintainers
Readme
Random Password Generator with AES Encryption and Decryption using Node crypto module
Random Password Generator helps create strong passwords to enhance security, while AES encryption is a robust algorithm used to secure data by transforming it into ciphertext, rendering it unreadable without the appropriate decryption key.
Installing
Using npm:
$ npm install @eternaljs/password-generator
Using yarn:
$ yarn add @eternaljs/password-generator
Usage
These examples assume you're in node, or something similar:
// JavaScript
const {
generateRandomPassword,
generateSecretAndSalt,
encryptPassword,
decryptPassword,
} = require("@eternaljs/password-generator");
// TypeScript
import {
generateRandomPassword,
generateSecretAndSalt,
encryptPassword,
decryptPassword,
} from "@eternaljs/password-generator";
// Generate Random password
const genPassword = generateRandomPassword();
// rwB5TxBTaRSa
// Generate Random Secret and salt
const { secret, salt } = generateSecretAndSalt();
// e2d9252464600187c7d12fdcd048d4ad
// dc6e22
const PASSWORD = "Testing@123";
const SECRET_KEY = "u6wq45p2gdk0b1mk5tz3uv8dg7uo9mlv";
const SECRET_SALT = "2CGF8G";
// Encrypt a password by using Node Crypto CBC with secret key and salt
const encryptPass = encryptPassword(SECRET_KEY, SECRET_SALT, PASSWORD);
// Uxw2Gn+bteN3oQEkWU6JgQ==
// Decrypt a password by using Node Crypto CBC with secret key and salt
const decryptPass = decryptPassword(SECRET_KEY, SECRET_SALT, encryptPass);
// Testing@123
License
MIT