2023-01-18 09:40:15 -05:00
|
|
|
import { ICryptoRepository } from '@app/domain';
|
2023-01-23 23:13:42 -05:00
|
|
|
import { Injectable } from '@nestjs/common';
|
2023-01-18 09:40:15 -05:00
|
|
|
import { compareSync, hash } from 'bcrypt';
|
2023-01-27 20:50:07 +00:00
|
|
|
import { randomBytes, createHash } from 'crypto';
|
2023-01-18 09:40:15 -05:00
|
|
|
|
2023-01-23 23:13:42 -05:00
|
|
|
@Injectable()
|
|
|
|
export class CryptoRepository implements ICryptoRepository {
|
|
|
|
randomBytes = randomBytes;
|
|
|
|
|
2023-01-27 20:50:07 +00:00
|
|
|
hashBcrypt = hash;
|
|
|
|
compareBcrypt = compareSync;
|
2023-01-23 23:13:42 -05:00
|
|
|
|
2023-01-27 20:50:07 +00:00
|
|
|
hashSha256(value: string) {
|
|
|
|
return createHash('sha256').update(value).digest('base64');
|
2023-01-23 23:13:42 -05:00
|
|
|
}
|
|
|
|
}
|