Files
gridpilot.gg/adapters/identity/services/InMemoryPasswordHashingService.ts
2025-12-16 11:52:26 +01:00

22 lines
868 B
TypeScript

/**
* In-Memory Password Hashing Service
*
* Provides basic password hashing and comparison for demo/development purposes.
* NOT FOR PRODUCTION USE - uses a simple string reversal as "hashing".
*/
import type { IPasswordHashingService } from '@core/identity/domain/services/PasswordHashingService';
export class InMemoryPasswordHashingService implements IPasswordHashingService {
async hash(plain: string): Promise<string> {
// In a real application, use a robust hashing library like bcrypt or Argon2.
// For demo, we'll just reverse the password and add a salt-like prefix.
const salt = 'demo_salt_';
return Promise.resolve(salt + plain.split('').reverse().join(''));
}
async verify(plain: string, hash: string): Promise<boolean> {
const hashedPlain = await this.hash(plain);
return Promise.resolve(hashedPlain === hash);
}
}