# password-hash-and-salt

> Simple, safe and straight-forward password hashing / salting for node.js

Latest version **0.1.4** (published 2016-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install password-hash-and-salt
pnpm add password-hash-and-salt
yarn add password-hash-and-salt
bun add password-hash-and-salt
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2016-09-20 |
| First published | 2014-05-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/password-hash-and-salt) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Florian Heinemann |
| Maintainers | florianheinemann |
| Keywords | crypto, node.js, node, hash, salt, password, pbkdf2 |

## Links

- npm: https://www.npmjs.com/package/password-hash-and-salt
- Repository: https://github.com/florianheinemann/password-hash-and-salt
- Issues: https://github.com/florianheinemann/password-hash-and-salt/issues
- npm.io page: https://npm.io/package/password-hash-and-salt

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 0.1.4 (latest) — 2016-09-20
- 0.1.3 — 2015-11-05
- 0.1.2 — 2014-05-02
- 0.1.1 — 2014-05-02
- 0.0.1 — 2014-05-02

## README

password-hash-and-salt
======================

This module provides straight-forward password hashing for node.js applications using default settings considered to be safe.

### Usage

First, install the module:

`$ npm install password-hash-and-salt --save`

Afterwards, usage is as simple as shown in the following example:
```javascript
var password = require('password-hash-and-salt');

var myuser = [];

// Creating hash and salt
password('mysecret').hash(function(error, hash) {
	if(error)
		throw new Error('Something went wrong!');

	// Store hash (incl. algorithm, iterations, and salt)
	myuser.hash = hash;

	// Verifying a hash
	password('hack').verifyAgainst(myuser.hash, function(error, verified) {
		if(error)
			throw new Error('Something went wrong!');
		if(!verified) {
			console.log("Don't try! We got you!");
		} else {
			console.log("The secret is...");
		}
	});
})

```

### Crypto
password-hash-and-salt uses node.js' internal crypto module. Hashes are generated with pbkdf2 using 10,000 iterations.

### Created hash
The created hash is of 270 characters length and is of the following format:
`pbkdf2$10000$hash$salt`

This allows for future upgrades of the algorithm and/or increased number of iterations in future version. It also simplifies storage as no dedicated database field for the salt is required.

### Credits and License
express-sslify is licensed under the MIT license. If you'd like to be informed about new projects follow   [@TheSumOfAll](http://twitter.com/TheSumOfAll/).

Copyright (c) 2013-2014 Florian Heinemann

---
_Source: https://npm.io/package/password-hash-and-salt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
