Files
cedar-api/src/shared/infrastructure/crypto/BcryptService.ts
2026-01-16 15:33:40 +08:00

16 lines
463 B
TypeScript

import bcrypt from "bcrypt";
import { uuidv7 } from "uuidv7";
import type { ICryptoService } from "@/shared/application/ports/ICryptoService.js";
export class BcryptService implements ICryptoService {
hashPassword(password: string): Promise<string> {
return bcrypt.hash(password, 10);
}
comparePassword(password: string, hash: string): Promise<boolean> {
return bcrypt.compare(password, hash);
}
randomId(): string {
return uuidv7();
}
}