Skip to content

Commit

Permalink
improvement: to hashing document
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed May 13, 2021
1 parent a6700e4 commit 0e8dbb8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion content/guides/security/hashing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
summary: Reference guide for the Hash module.
---

AdonisJS Hash module allows you to hash the values using Bcrypt or Argon2, with the option to add a custom hashing driver.
AdonisJS Hash module allows you to hash the values using **Bcrypt** or **Argon2**, along with the option to add a custom hashing driver.

You can configure the driver of your choice inside the `config/hash.ts` file.

Expand All @@ -11,6 +11,12 @@ const hashConfig: HashConfig = {
default: Env.get('HASH_DRIVER', 'argon'),

list: {
/**
* Make sure to install the driver from npm
* ------------------------------------
* npm i phc-argon2
* ------------------------------------
*/
argon: {
driver: 'argon2',
variant: 'id',
Expand All @@ -19,6 +25,13 @@ const hashConfig: HashConfig = {
parallelism: 1,
saltSize: 16,
},

/**
* Make sure to install the driver from npm
* ------------------------------------
* npm i phc-bcrypt
* ------------------------------------
*/
bcrypt: {
driver: 'bcrypt',
rounds: 10,
Expand Down Expand Up @@ -85,6 +98,8 @@ export default class User extends BaseModel {
}
```

---

### verify

You cannot convert hashed values back to a plain string, and you can only verify that a given plain-text string corresponds to a given hash.
Expand All @@ -95,6 +110,8 @@ if (await Hash.verify(hashedValue, plainTextValue)) {
}
```

---

### needsReHash

Find if a previously hashed value needs a rehash. This method returns true if the work factor used by the hasher has changed since the password was hashed.
Expand Down

0 comments on commit 0e8dbb8

Please sign in to comment.