Skip to content

Commit

Permalink
🚀 Updated env for encrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Jul 18, 2024
1 parent a78e531 commit 05946f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ export class EncryptionService {
private iv = crypto.randomBytes(16);

constructor(private env: EnvironmentService, private logger: LoggerService) {
this.secretKey = this.env.getCryptoKey();
this.secretKey = process.env.ENCRYPT_CRYPTO_SECRET_KEY;
}

encrypt(data: string): string {
try {
if (!data) throw new Error('Cant encrypt empty string');
const cipher = crypto.createCipheriv(
'aes-256-cbc',
Buffer.from(this.secretKey, 'utf-8'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class ConnectionsStrategiesService {
for (let i = 0; i < attributes.length; i++) {
const attribute_slug = attributes[i];
const value = values[i];
const encrypted_value = this.crypto.encrypt(value);
//create all attributes (for oauth => client_id, client_secret)
const attribute_ = await this.prisma.cs_attributes.create({
data: {
Expand All @@ -102,7 +103,7 @@ export class ConnectionsStrategiesService {
const value_ = await this.prisma.cs_values.create({
data: {
id_cs_value: uuidv4(),
value: this.crypto.encrypt(value),
value: encrypted_value,
id_cs_attribute: attribute_.id_cs_attribute,
},
});
Expand Down

0 comments on commit 05946f8

Please sign in to comment.