# p4ssw0rd

> Hash passwords with SHA-256 + bcrypt

Latest version **1.0.7** (published 2021-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install p4ssw0rd
pnpm add p4ssw0rd
yarn add p4ssw0rd
bun add p4ssw0rd
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2021-09-26 |
| First published | 2019-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 77.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Tuomas Pöyry |
| Maintainers | munkkeli |
| Keywords | nodejs, typescript, bcrypt, sha256, security, password |

## Links

- npm: https://www.npmjs.com/package/p4ssw0rd
- Repository: https://github.com/Munkkeli/p4ssw0rd
- Homepage: https://github.com/Munkkeli/p4ssw0rd#readme
- Issues: https://github.com/Munkkeli/p4ssw0rd/issues
- npm.io page: https://npm.io/package/p4ssw0rd

## Dependencies (2)

- [bcryptjs](https://npm.io/package/bcryptjs.md) ~2.4.3
- [@types/bcryptjs](https://npm.io/package/@types/bcryptjs.md) ~2.4.2

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2021-09-26
- 1.0.6 — 2021-03-30
- 1.0.5 — 2020-09-11
- 1.0.4 — 2020-07-07
- 1.0.3 — 2019-07-18
- 1.0.2 — 2019-07-18
- 1.0.1 — 2019-07-18
- 1.0.0 — 2019-07-17

## README

# p4ssw0rd

[![Build Status](https://travis-ci.com/Munkkeli/p4ssw0rd.svg?branch=master)](https://travis-ci.com/Munkkeli/p4ssw0rd)

Generates secure password hashes with SHA-256 and bcrypt. Supports TypeScript.

```bash
npm install p4ssw0rd
```

```js
import * as p4ssw0rd from 'p4ssw0rd';
```

- No password length limit
- Output hash is always 60
- Configurable bcrypt cost
- Only one dependency!

Uses [bcrypt.js](https://github.com/dcodeIO/bcrypt.js) to generate the bcrypt hash. For SHA-512 hash the [Node.js Crypto Module](https://nodejs.org/api/crypto.html) is used.

## Usage

### Hash

```js
const hash = p4ssw0rd.hash(password, options?);
```

Creates a hash from supplied password. Hash will always be 60 characters long.

### Check

```js
if (p4ssw0rd.check(password, hash, options?)) {
  // Passwords match
}
```

Validates the input password against a stored hash. Returns true if password is correct.

### Simulate

```js
p4ssw0rd.simulate();
```

Simulates validating a real hash. Usefull against timing attacks on login pages.

### Options

```js
{
  cost: 10, // The "cost" of bcrypt hash, default is 10
}
```

## Contributing

1. Clone the git repository
2. `npm install` (Make sure `NODE_ENV` is not set to `production`)
3. Make changes
4. `npm run build`
5. `npm test`

That's it!

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