https://github.com/zephinzer/authasher
Sub-component of authentication module to handle hashing for password storage
https://github.com/zephinzer/authasher
Last synced: 2 months ago
JSON representation
Sub-component of authentication module to handle hashing for password storage
- Host: GitHub
- URL: https://github.com/zephinzer/authasher
- Owner: zephinzer
- Created: 2017-04-03T10:47:55.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-04T16:53:58.000Z (about 8 years ago)
- Last Synced: 2025-03-06T09:42:59.093Z (3 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Authasher
[](https://codeclimate.com/github/zephinzer/authasher)
[](https://travis-ci.org/zephinzer/authasher)## Compatibility
Authasher is tested to be compatible with the following versions of Node: `0.10.42`, `0.12.13`, `4`, `5`, `6`, `7`.## Installation & Usage
Install authasher with NPM```bash
# npm install authasher --save
```Or install it with Yarn
```bash
# yarn add authasher
```Include and use it in your project:
```javascript
const authasher = require('authasher');
const password = 'p@ssw0rd';
const hashedToken = authasher.create(password);
const result = authasher.validate(password, hashedToken);
console.log(result);
/**
* result = {
* valid: true,
* expired: false,
* corrupt: false
* }
**/
```## Options
The available options to modify the hashing are:
- `algorithm`
- changes the encryption algorithm
- defaults to `aes192`
- `hashing`
- changes the hashing algorithm
- defaults to `sha512`
- `timeValidity`
- time that the hashed token should be valid for
- `iterations`
- number of PBKDF2 iterations
- defaults to `8192`
- `keyLength`
- length of generated keys
- defaults to `32`## API
### `authasher::create(password, options)`
- `password` : String
- the password you wish to hash
- `options` : Object
- optionsThis function creates a hash token from the provided password. Returns a hash token of type `String`.
### `authasher::validate(password, storedToken, options)`
- `password` : String
- the challenging password to validate
- `storedToken` : String
- a stored token generated from `authasher::create`
- `options` : Object
- optionsThis function validates a hash token generated from `authasher::create` (`:storedToken`) with a challenge password (`password`). Returns an object of the following structure:
```json
{
valid : Boolean,
expired : Boolean,
corrupt : Boolean
}
```## Contributing
### Overview
Fork it, make your changes and raise a pull request. Please include the relevant tests in the `/test` folder.### Installing the devDependencies
After forking the repository and cloning it locally, run the following command to install the devDependencies with NPM:```bash
# npm install --only=dev
```Or run the analogous command to install it with Yarn:
```bash
# yarn install
```
### Testing
Tests are written with the `mocha` testing framework and the `chai` assertion library.## Changelog
- Version 1.0.0
- Initial release