django-pgcrypto-fields icon indicating copy to clipboard operation
django-pgcrypto-fields copied to clipboard

Pass options to pgp_sym_encrypt

Open SiddharthPant opened this issue 5 years ago • 5 comments

pgp_sym_encrypt function supports certain options. For example by default it uses AES128 algorithm to encrypt but you can customize pgp_sym_encrypt(data, psw, 'compress-algo=1, cipher-algo=aes256'). Is there a way I can provide the cipher-algo option with value AES256 when I create CharPGPSymmetricKeyField or maybe in the settings file? If there is not then could there please be an enhancement that can be made for this?

SiddharthPant avatar May 30 '19 12:05 SiddharthPant

@SiddharthPant It's currently not configurable in this package but a PR would be welcome.

peterfarrell avatar Sep 30 '19 19:09 peterfarrell

This is also related to #89

peterfarrell avatar Sep 30 '19 19:09 peterfarrell

@peterfarrell

What if you did something like this:

>>> ("pgp_sym_encrypt(%s, '{}', '{}')::%s" % ("foo", "bar")).format(2, 3)
"pgp_sym_encrypt(foo, '2', '3')::bar"

.format picks up the {}, % picks up the %s

9mido avatar Dec 18 '21 02:12 9mido