I am looking to symmetrically encrypt/decrypt information in a database. This info consists of short pieces of information, which need to be individually encrypted when a specific method is called.

I have been researching using AES_256 in GCM mode, but keep coming across the recommendation that I should not "roll my own cryptography protocol". see these links for examples

Lessons learned and misconceptions regarding encryption and cryptology


I need to actually incorporate the encrypting/decrypting in code.

Can I viably use GPG or PGP to encrypt/decrypt code, and if so how?

If not, any suggestions as to the best library to use for AES in GCM would be appreciated.



1 Answer 1


The central part of PGP/GPG is the asymmetric cryptography. It does not make sense to use GPG without that part because the rest is just simple symmetric en-/decryption.

Using the cipher algorithms from GPG also does not make sense as Dot.Net has them already implemented. I am not sure if the GCM mode is also present but if not you can still use the Dot.Net version of BounyCastle, which has GCM support.

Since you don't have a database provider that supports encryption, in my opinion your only option is to develop your "own protocol".

How many keys to use and how to cipher what with which key depends on the security needs of the data you are storing. Make sure to discuss your final design intensively here on Stackoverflow or on the IT Security branch.

BTW: Even if GCM outputs a cipher text exactly as long as the plain text it requires further parameters like IV and authentication tag (auth tag is optional) which have to be saved. Therefore the data to be saved is again larger than the plain text. But as long as you don't have millions of records this doesn't make IMHO a big difference nowadays.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .