mbdavid / LiteDB

LiteDB - A .NET NoSQL Document Store in a single data file
http://www.litedb.org
MIT License
8.6k stars 1.25k forks source link

[QUESTION] please need example for https://www.litedb.org/docs/encryption/ #2520

Open qart2003 opened 3 months ago

qart2003 commented 3 months ago

Hey anybody,

I have read about Encryption - https://www.litedb.org/docs/encryption/ How can I use it?

In the project I should store patients data and it's sensitive data should be encrypted/decrypted

marss72 commented 1 month ago

If you can derive an encryption key for each patient, you might want to individually encrypt each document by for example making each document contain an ID and an encrypted byte array, that when decrypted can be a JSON string, that then can be deserialized and will contain the secret patient data.

If you want to encrypt the whole database using one key, you can provide a password when opening the database in the connection string. You will need to rebuild the database if it's not encrypted already.

Connection string to introduce encryption: https://www.litedb.org/docs/connection-string/. Make sure to follow the latest encryption standards to make the encryption effective. Never hard-code the password or store it as plain text.