# happn-password-hash-and-salt

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

Latest version **1.2.1** (published 2020-04-08) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2020-04-08 |
| First published | 2017-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 46 |
| Author | Florian Heinemann |
| Maintainers | smc-tenacious |
| Keywords | crypto, node.js, node, hash, salt, password, pbkdf2 |

## Links

- npm: https://www.npmjs.com/package/happn-password-hash-and-salt
- Repository: https://github.com/florianheinemann/password-hash-and-salt
- Homepage: https://github.com/happner/password-hash-and-salt
- Issues: https://github.com/happner/password-hash-and-salt/issues
- npm.io page: https://npm.io/package/happn-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

- 1.2.1 (latest) — 2020-04-08
- 1.2.0 — 2019-04-15
- 1.1.0 — 2017-06-08
- 1.0.0 — 2017-06-08

## README

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

forked from https://github.com/florianheinemann/password-hash-and-salt.git
version 1.1.4

####This module provides straight-forward password hashing for node.js applications using default settings considered to be safe. SHA512 is used by default, also backward compatible with previous versions that used SHA1.


### Usage

First, install the module:

`$ npm install happn-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$digest`

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
Modified by S. Bishop

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