Closed Shashi-GS closed 3 years ago
Seems dependent on https://github.com/typeorm/typeorm/issues/4268.
Try using subscribers.
Oh! I tried to use subscribers. Still no luck.
13|api | Error: Invalid IV length
13|api | at Decipheriv.createCipherBase (internal/crypto/cipher.js:79:18)
13|api | at Decipheriv.createCipherWithIV (internal/crypto/cipher.js:115:20)
13|api | at new Decipheriv (internal/crypto/cipher.js:254:22)
13|api | at Object.createDecipheriv (crypto.js:117:10)
13|api | at Object.decryptData (/home/pulse/teamconnect/pulse-api-team/node_modules/typeorm-encrypted/lib/crypto.js:36:29)
13|api | at Object.decrypt (/home/pulse/teamconnect/pulse-api-team/node_modules/typeorm-encrypted/lib/entity.js:67:53)
13|api | at AutoEncryptSubscriber.afterLoad (/home/pulse/teamconnect/pulse-api-team/node_modules/typeorm-encrypted/lib/subscribers/AutoEncryptSubscriber.js:30:18)
13|api | at /home/pulse/teamconnect/pulse-api-team/node_modules/typeorm/subscriber/Broadcaster.js:285:58
13|api | at Array.forEach (
first access itself its returning this. any idea with this?
A couple of questions for you?
type: "varchar",
nullable: false,
encrypt: {
key: "d85117047fd06d3afa79b6e44ee3a52eb426fc24c3a2e3667732e8da0342b4da",
algorithm: "aes-256-cbc",
ivLength: 16
}
})```
Sorry for the late response.
Here is a step by step way of doing it: https://github.com/generalpiston/typeorm-encrypted/issues/19#issuecomment-650979933.
Thank You for the quick response. Yes I am able to do this with some work around. There are couple of problems, please let me know is there any way I can solve this.
From typeorm docs:
You can define a method with any name in the entity and mark it with @BeforeUpdate and TypeORM will call it before an existing entity is updated using repository/manager save.
You cannot use typeorm-encrypted
and perform complex queries. The reason being the contents in the database are encrypted. You'll probably want database level encryption like MySQL data-at-rest encryption or MongoDB data-at-rest encryption.
I am trying to use as transformer, its not working.