Giter VIP home page Giter VIP logo

passwuert's Introduction

Hash password and compare to hashed.

Why

Hash passwords to not store passwords in plaintext. Having passwords in plaintext is risky, because they can be leaked as soon as the system or the administrator is compromised. Also it is forbidden to store password in plaintext files.

To still be able to verify a password we simply hash it again with the same function. If the result is the same then it means the inputs were the same.

We add salt, to slow down potential hackers. The salt is random, so that if 2 people use the same password, the data will not look the same.

Installation

npm i passwuert

Usage

See example

passwuert.js

import {
    hashPasswordWithRandomSalt,
    comparePasswordToHashed,
} from "passwuert"; // async
// or from "passwuert/lib/passwuertNodeLegacy.js" // sync



// deno
import {
    hashPasswordWithRandomSalt,
    comparePasswordToHashed,
} from "https://unpkg.com/passwuert/lib/passwuert.js"; // async

// password is a string
// digestname is optional, default sha512 or SHA-512
// keylen is optional, the length of the result hash, default 16
// use async keyword for async version
const { hash, salt, iterations } = hashPasswordWithRandomSalt(password, digestName, keylen);
// again digestName and keylen are optional but should be the same as used above
const samePassword = comparePasswordToHashed(password, {hash, salt, iterations}, digestName, keylen)

digestname choices

  • BLAKE2b512
  • BLAKE2s256
  • MD4
  • MD5
  • MD5-SHA1
  • MDC2
  • RIPEMD160
  • SHA1
  • SHA224
  • SHA256
  • SHA3-224
  • SHA3-256
  • SHA3-384
  • SHA3-512
  • SHA384
  • SHA512
  • SHA512-224
  • SHA512-256
  • SHAKE128
  • SHAKE256
  • SM3

About

Difference between passwuertNodeLegacy.js and passwuertNode.js

passwuertNode.js imports passwuert.js which uses webcrypto. passwuertNodeLegacy uses custom Node.js specific functions that existed before and the functions are sync.

Difference with bcrypt

  • Does not depend on Python or C++
  • Uses modern WebCrypto API
  • Works in the browser and Deno too
  • hash, salt and iterations are returned as 3 separate items
  • Requires Node18+

Changelog

Changelog

License

CC0

passwuert's People

Contributors

grossacasac avatar

Stargazers

 avatar Maik Diepenbroek avatar Peter Aleksander Bizjak avatar Michael J. Ryan avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.