budibase/packages/auth/src/hashing.js

14 lines
322 B
JavaScript
Raw Normal View History

2021-04-07 12:33:16 +02:00
const bcrypt = require("bcryptjs")
const env = require("./environment")
2021-04-07 12:33:16 +02:00
const SALT_ROUNDS = env.SALT_ROUNDS || 10
2021-04-07 12:33:16 +02:00
exports.hash = async data => {
const salt = await bcrypt.genSalt(SALT_ROUNDS)
return bcrypt.hash(data, salt)
}
exports.compare = async (data, encrypted) => {
return bcrypt.compare(data, encrypted)
}