mirror of
https://github.com/IT4Change/gradido.git
synced 2026-03-29 13:45:35 +00:00
15 lines
636 B
TypeScript
15 lines
636 B
TypeScript
import { User } from 'database'
|
|
|
|
// import { logger } from '@test/testSetup' getting error "jest is not defined"
|
|
import { SecretKeyCryptographyCreateKey, getUserCryptographicSalt } from './EncryptorUtils'
|
|
|
|
export const encryptPassword = async (dbUser: User, password: string): Promise<bigint> => {
|
|
const salt = getUserCryptographicSalt(dbUser)
|
|
return SecretKeyCryptographyCreateKey(salt, password)
|
|
}
|
|
|
|
export const verifyPassword = async (dbUser: User, password: string): Promise<boolean> => {
|
|
const encryptedPassword = await encryptPassword(dbUser, password)
|
|
return dbUser.password.toString() === encryptedPassword.toString()
|
|
}
|