0

In my project I must implement a feature for encrypting some information when it is written into the database, and decrypt the information when it is reloaded.

Should this concept be implemented in the domain model? Or is it cleaner / more maintainable to do these operations in the repository?

  • Is the encryption of the data something that the domain experts talk about, or is it just a technical measure to prevent leaking sensitive information? If the second, how sensitive is the information? – Bart van Ingen Schenau Aug 29 '18 at 12:43
  • the second options , mmm very sensitive I'd say – BruceStackOverFlow Aug 29 '18 at 12:56
  • 1
    Does the database provide encryption at rest? And if yes, does this satisfy your requirements? – kdgregory Aug 29 '18 at 14:06
  • The db is momgodb bat my question remaining – BruceStackOverFlow Aug 29 '18 at 16:38
2

The encryption functionality does not belong to the domain model, if it is only a technical measure to protect sensitive data. Why ? Because it's an implementation detail of the storage layer; you could very well use a database that has a build-in encryption capability.

Data encryption functionality could belong to the domain level, in cases where the domain is about cryptography, for example if your domain processes include encryption and decryption explicitly. Generally you then have also some key management requirements (banking systems, or management of classified information).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.