2021-03-29 18:32:05 +02:00
|
|
|
// TODO: REMOVE
|
|
|
|
|
2020-05-07 11:53:34 +02:00
|
|
|
const bcrypt = require("bcryptjs")
|
2020-05-14 16:12:30 +02:00
|
|
|
const env = require("../environment")
|
2020-04-23 15:37:08 +02:00
|
|
|
|
2020-05-14 16:12:30 +02:00
|
|
|
const SALT_ROUNDS = env.SALT_ROUNDS || 10
|
2020-04-23 15:37:08 +02:00
|
|
|
|
2021-05-04 12:32:22 +02:00
|
|
|
exports.hash = async data => {
|
2020-05-07 11:53:34 +02:00
|
|
|
const salt = await bcrypt.genSalt(SALT_ROUNDS)
|
|
|
|
const result = await bcrypt.hash(data, salt)
|
|
|
|
return result
|
|
|
|
}
|
2020-04-23 15:37:08 +02:00
|
|
|
|
2020-05-07 11:53:34 +02:00
|
|
|
exports.compare = async (data, encrypted) =>
|
|
|
|
await bcrypt.compare(data, encrypted)
|