budibase/packages/server/src/utilities/bcrypt.js

16 lines
365 B
JavaScript
Raw Normal View History

// 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-05-14 16:12:30 +02:00
const SALT_ROUNDS = env.SALT_ROUNDS || 10
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-05-07 11:53:34 +02:00
exports.compare = async (data, encrypted) =>
await bcrypt.compare(data, encrypted)