doge-passwd
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

doge-passwd

Generate strong password hashes easily.

import { hash, verify } from 'doge-passwd';

let password = `some_user_input`;
let hash_length = 64;

// Create hash, looks like this: yBZnekfk3zlGhJE78~0vkGtvpfC6EOnFIWAs9YasaOqRuOHMECZgWQe~7J8N4TWV
let hashed = hash(password, hash_length);

// Max length is 80, there is no lower bound on length, but more bytes = more security
// Longer hashes will generate incorrectly, and trying to verify() them will yield chaos
// Hash will always only use SQL-safe URL-safe characters, /[0-9a-z~_]/i

console.log(verify(password, hashed)); // true

methods

Regular - hash(), verify()

Hex - hash_hex(), verify_hex()

Always use the correct verify() function!

length

For regular hashes, length must a multiple of 8, <= 80.

For hex hashes, length must be a multiple of 2, <= 128.

Longer length = more security!

Frontend Authentication

You can use this package for frontend authentication.

It is likely not a good idea.

However, if your database does get leaked, doge-passwd hashes will be much harder to crack than, for example, a simple SHA-256.

Readme

Keywords

none

Package Sidebar

Install

npm i doge-passwd

Weekly Downloads

2

Version

0.1.4

License

GPL-3.0-or-later

Unpacked Size

53 kB

Total Files

23

Last publish

Collaborators

  • realprokopschield