I'm trying to duplicate a column, but I would like to encrypt it with not very high data value, and I was able to do it, well, just the first part.
CREATE TABLE probeta ( id int primary key, numero_documento varchar , documento_prefijo varchar, numero_documento_crypt varchar, documento_prefijo_crypt varchar );
With this basic query, I can do what I need
UPDATE probeta SET numero_documento_crypt =(pgp_sym_encrypt(numero_documento::varchar, 'psw','compress-algo=1, cipher-algo=aes')) where 1=1;
The length of the encrypted field is very long, about 140 characters.
When I try to do it as follows:
UPDATE probeta SET numero_documento_crypt = encrypt(numero_documento, 'key', 'aes') where 1=1;
this to try to decrease the size of the field, but I have not succeeded.
The idea of the process is to deliver encrypted data, but, when you need to know what value an encrypted data means, I can answer it, so do not use one-way encryption.
i try whit this:
UPDATE probeta SET numero_documento_crypt =crypt('numero_documento', gen_salt('des')) where 1=1;
And this is the result:
the doc_encrypt is short, and is unique, this solve my problem, butttt, again, the problem in this case is, that I cannot decipher that value, because it does not receive any seeds.
The idea of this encryption is to pass only the encrypted data to a user, but when, when I need to know what value it refers to, I can decipher it.
Thanks to all who gave their opinion, I hope I have corrected what they required.
Could someone give me an opinion?