0

I'm trying to use the AES-GCM encryption and I didn't see a good solution on how the encrypted data is stored

I'm following the implementation recommended here https://www.scottbrady91.com/c-sharp/aes-gcm-dotnet#aesgcm and it seems once the data is encrypted we need 3 separate pieces to decrypt it (nonce, tag and the encrypted data).

In our previous implementation (AES-CBC), we simply had the encrypted string for the password and we stored it in our DB along with other user details.

Are there any recommended techniques to save the details needed for decryption? The blog above says a common technique is to concatenate everything [Nonce (12B) | Ciphertext (*B) | Tag (16B)].

Would converting all the byte arrays to base64 string, concatenating them and saving that string in password field in DB be a good approach?

If the question isn't appropriate for this forum, can someone please recommend some other forum?

3
  • 1
    Asking for recommendations (for tools/libraries) or best approaches is off-topic on SO. Do you have a problem with your current implementation? Where are you stuck? How to Ask - How to create a minimal reproducible example
    – DarkBee
    Commented Oct 19, 2023 at 12:59
  • 1
    Aside... if your system is still dealing with passwords then please use salt-and-hashing techniques to store and validate passwords instead of encryption. If you can decrypt it so can somebody else. Commented Oct 19, 2023 at 13:15
  • ^ 100% correct - Some extra reading materials about this can be found here
    – DarkBee
    Commented Oct 19, 2023 at 13:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.