MonTPE/backend/src/common/crypto.ts
Tony AVERTY 061f76a527 chore: import initial du projet MonTPE (TapTP)
Backend NestJS/Prisma, application mobile Expo (Tap to Pay Stripe),
tableau de bord web Vite et documentation (cadrage en brouillon,
décisions d'architecture). Secrets et fichiers locaux exclus par .gitignore.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-15 18:26:14 +02:00

11 lines
433 B
TypeScript

import { createHash, randomBytes } from 'crypto';
/** Token opaque à transmettre au client (jamais stocké en clair). */
export function generateToken(bytes = 32): string {
return randomBytes(bytes).toString('base64url');
}
/** Empreinte stockée en base. SHA-256 suffit : le token est déjà aléatoire et long. */
export function hashToken(token: string): string {
return createHash('sha256').update(token).digest('hex');
}