I'm trying to set chipher algorithm(postgres 9.6 or 12 / pgcrypto module) for encryption and decryption. But realized that pgp_sym_encrypt
and pgp_sym_decrypt
works with different algorithms. I didn't understand why below statement works with different chipher algorithm that encrypted with aes128
and decrypted with aes256
or vise versa, but expected error. Is there any mistake?
select pgp_sym_decrypt(pgp_sym_encrypt('secretvalue', 'secretkey', 'cipher-algo=aes128'), 'secretkey', 'cipher-algo=aes256');
select pgp_sym_decrypt(pgp_sym_encrypt('secretvalue', 'secretkey', 'cipher-algo=aes256'), 'secretkey', 'cipher-algo=aes128');