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

14 lines
348 B
JavaScript
Raw Normal View History

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
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)