@@ -31,26 +31,26 @@ export class AccountService {
3131 private tokenService : PasswordTokenService ,
3232 private mailingService : MailingService
3333 ) { }
34-
3534 private async hashPassword ( password : string ) : Promise < string > {
3635 return await hash ( password , Number ( process . env . SALT_ROUNDS ) ) ;
3736 }
3837 private encrypt ( text : string ) {
39- const cipher = crypto . createCipheriv (
40- 'aes-256-cbc' ,
41- process . env . SECRET_KEY_CRYPTO ,
42- process . env . IV
43- ) ;
38+ const key = Buffer . from ( process . env . SECRET_KEY_CRYPTO , 'hex' ) ;
39+ const iv = Buffer . from ( process . env . IV , 'hex' ) ;
40+
41+ const cipher = crypto . createCipheriv ( 'aes-256-cbc' , key as any , iv as any ) ;
4442 let encrypted = cipher . update ( text , 'utf8' , 'hex' ) ;
4543 encrypted += cipher . final ( 'hex' ) ;
4644 return encrypted ;
4745 }
4846
4947 private decrypt ( text : string ) {
48+ const key = Buffer . from ( process . env . SECRET_KEY_CRYPTO , 'hex' ) ;
49+ const iv = Buffer . from ( process . env . IV , 'hex' ) ;
5050 const decipher = crypto . createDecipheriv (
5151 'aes-256-cbc' ,
52- process . env . SECRET_KEY_CRYPTO ,
53- process . env . IV
52+ key as any ,
53+ iv as any
5454 ) ;
5555 let decrypted = decipher . update ( text , 'hex' , 'utf8' ) ;
5656 decrypted += decipher . final ( 'utf8' ) ;
0 commit comments