-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update readme and generate api docs
- Loading branch information
1 parent
0470713
commit 87b7d62
Showing
23 changed files
with
4,929 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,93 @@ | ||
<div align="center"> | ||
<img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1557762307/poppinss_iftxlt.jpg" width="600px"> | ||
</div> | ||
|
||
# Password hashing | ||
> Module to hash values with support for [PHC string format](https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md) | ||
[![circleci-image]][circleci-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url] | ||
|
||
This module is used by [AdonisJs](https://adonisjs.com) to hash user password with first class support for upgrading logic. A big thanks to the author of [uphash](https://github.com/simonepri/upash), who inspired me to use [PHC string format](https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md). I would have used uphash directly, but the user facing API is different from what I desire. | ||
|
||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
## Table of contents | ||
|
||
- [@poppinss/hash](#poppinsshash) | ||
- [Change log](#change-log) | ||
- [Contributing](#contributing) | ||
- [Authors & License](#authors--license) | ||
- [Features](#features) | ||
- [Usage](#usage) | ||
- [Switching drivers](#switching-drivers) | ||
- [Adding custom drivers](#adding-custom-drivers) | ||
- [API Docs](#api-docs) | ||
- [Maintainers](#maintainers) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
# @poppinss/hash | ||
## Features | ||
1. Support for multiple hashing algorithms. | ||
2. Option to extend and add your own hashing algorithms. | ||
3. Wraps the hash output to a [PHC string format](https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md), this allows upgrading user passwords, when the underlying configuration changes. | ||
|
||
## Usage | ||
Install the package from npm registry as follows: | ||
|
||
```sh | ||
npm i @poppinss/hash | ||
|
||
# yarn | ||
yarn add @poppinss/hash | ||
``` | ||
|
||
[![circleci-image]][circleci-url] | ||
[![npm-image]][npm-url] | ||
![](https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript) | ||
and then use it as follows: | ||
|
||
## Change log | ||
```ts | ||
import { Hash } from '@poppinss/hash' | ||
const hash = new Hash(iocContainer, config) | ||
|
||
The change log can be found in the [CHANGELOG.md](CHANGELOG.md) file. | ||
const hashedValue = await hash.hash('password') | ||
await hash.verify(hashedValue) | ||
|
||
## Contributing | ||
await hash.needsRehash(hashedValue) // false | ||
``` | ||
|
||
Everyone is welcome to contribute. Please go through the following guides, before getting started. | ||
## Switching drivers | ||
You can switch drivers using the `driver` method. | ||
|
||
1. [Contributing](https://adonisjs.com/contributing) | ||
2. [Code of conduct](https://adonisjs.com/code-of-conduct) | ||
```ts | ||
import { Hash } from '@poppinss/hash' | ||
const hash = new Hash(iocContainer, config) | ||
|
||
await hash.driver('bcrypt').hash('password') | ||
``` | ||
|
||
## Authors & License | ||
[thetutlage](https://github.com/thetutlage) and [contributors](https://github.com/poppinss/hash/graphs/contributors). | ||
## Adding custom drivers | ||
The custom drivers can be added using the `extend` method. | ||
|
||
MIT License, see the included [MIT](LICENSE.md) file. | ||
```ts | ||
import { Hash, HashDriverContract } from '@poppinss/hash' | ||
const hash = new Hash(iocContainer, config) | ||
|
||
class Scrypt implements HashDriverContract {} | ||
|
||
hash.extend('scrypt', (container) => { | ||
return new Scrypt() | ||
}) | ||
``` | ||
|
||
## API Docs | ||
Following are the autogenerated files via Typedoc | ||
|
||
* [API](docs/README.md) | ||
|
||
## Maintainers | ||
[Harminder virk](https://github.com/thetutlage) | ||
|
||
[circleci-image]: https://img.shields.io/circleci/project/github/poppinss/hash/master.svg?style=for-the-badge&logo=circleci | ||
[circleci-url]: https://circleci.com/gh/poppinss/hash "circleci" | ||
|
||
[npm-image]: https://img.shields.io/npm/v/@poppinss/hash.svg?style=for-the-badge&logo=npm | ||
[npm-url]: https://npmjs.org/package/@poppinss/hash "npm" | ||
|
||
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript | ||
|
||
[license-url]: LICENSE.md | ||
[license-image]: https://img.shields.io/aur/license/pac.svg?style=for-the-badge |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.