typeorm-encrypted icon indicating copy to clipboard operation
typeorm-encrypted copied to clipboard

It doesn't encrypt the default value of the column

Open uragun91 opened this issue 3 years ago • 2 comments

When you specify column like this:

@Column({
    default: 'TEST_DATA',
    transformer: new EncryptionTransformer({
      key: '<key>',
      algorithm: 'aes-128-cbc',
      ivLength: 16,
    }),
  })
  encryptedColumn: string;

It inserts exact value that is specified in the default field instead of encrypted one.

I'm testing it with autoLoadEntities === true

uragun91 avatar Dec 24 '21 15:12 uragun91

Hmm... interesting use case... default values are usually set in the schema. The current implementation doesn't do any encryption in DDLs. If it did, then every time the key changes, it would require a schema update.

generalpiston avatar Dec 24 '21 16:12 generalpiston

hello,

same error when I do :

@Column({
    nullable: true,
    default: null,
    transformer: new EncryptionTransformer(MyEncryptionTransformerConfig),
  })
  @Nullable(String)
  public tags: string;

Thanks

Paul75 avatar Nov 14 '22 14:11 Paul75