I am trying to use a symmetric key to encrypt and decrypt a field in Postgres 14.10.
I am encrypting per documentation like so:
select pgp_sym_encrypt('data', 'password');
I am feeding the return of the above into decrypt data:
select pgp_sym_decrypt_bytea('0xC30D04090302F39E612C4A8DD96974D23A011F61B98966A502BC5354962D9B34E5EA3963A347E01B19FC334E7B2FF716978BD74EE4322DBEC4E2118E4AAB471A54D76EDEA25309287095A5', 'password');
The error is [39000] ERROR: Wrong key or corrupt data
I have tried specifying options such as 'compress-algo=1, cipher-algo=aes256' and casting the encrypted data as ::bytea, but I always get the same error.
How can I encrypt and decrypt with a symmetric key?