2022-11-24 19:48:51 +01:00
|
|
|
import env from "../environment"
|
2023-11-20 21:52:29 +01:00
|
|
|
|
2023-03-30 17:35:25 +02:00
|
|
|
export * from "../docIds/newid"
|
2022-09-13 19:00:10 +02:00
|
|
|
const bcrypt = env.JS_BCRYPT ? require("bcryptjs") : require("bcrypt")
|
2021-04-07 12:33:16 +02:00
|
|
|
|
2021-04-14 15:13:48 +02:00
|
|
|
const SALT_ROUNDS = env.SALT_ROUNDS || 10
|
2021-04-07 12:33:16 +02:00
|
|
|
|
2022-11-24 19:48:51 +01:00
|
|
|
export async function hash(data: string) {
|
2021-04-07 12:33:16 +02:00
|
|
|
const salt = await bcrypt.genSalt(SALT_ROUNDS)
|
|
|
|
return bcrypt.hash(data, salt)
|
|
|
|
}
|
|
|
|
|
2022-11-24 19:48:51 +01:00
|
|
|
export async function compare(data: string, encrypted: string) {
|
2021-04-07 12:33:16 +02:00
|
|
|
return bcrypt.compare(data, encrypted)
|
|
|
|
}
|