aboutsummaryrefslogtreecommitdiffstats
path: root/providers/LegacyHashDriver.ts
blob: eb2a263561be8686326edab5ba14cf0fda10dc2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import bcrypt from 'bcrypt'
import { HashDriverContract } from '@adonisjs/core/hash'

/**
 * Implementation of custom bcrypt driver
 */
export class LegacyHashDriver implements HashDriverContract {
  /**
   * Hash value
   */
  public async make(value: string) {
    return bcrypt.hash(value, 10)
  }
  /**
   * Verify value
   */
  public async verify(hashedValue: string, plainValue: string) {
    return bcrypt.compare(plainValue, hashedValue)
  }
}