gradido/backend/src/password/PasswordEncryptor.ts
einhornimmond 07a80b2df7 linting
2025-12-04 13:01:01 +01:00

14 lines
556 B
TypeScript

import { User } from 'database'
import { getUserCryptographicSalt, SecretKeyCryptographyCreateKey } 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()
}