generalpiston / typeorm-encrypted

Encrypted field for typeorm.
MIT License
75 stars 19 forks source link

It doesn't encrypt the default value of the column #46

Open uragun91 opened 2 years ago

uragun91 commented 2 years ago

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

generalpiston commented 2 years ago

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.

Paul75 commented 1 year ago

hello,

same error when I do :

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

Thanks