W
W
writer_21592021-10-01 13:39:22
Database design
writer_2159, 2021-10-01 13:39:22

How to store encrypted data in a database?

There is a need to encrypt some data that is stored in the database.
At the moment I'm leaning towards the cassandra database stack and RSA 2048 encryption

. For example, there is a table of users id, name, phone. The goal is to encrypt data from the phone column.

And here I have 2 options:
1) enter encrypted data directly in the user table in the phone column
2) select a separate table id, keyId, value (keyId is the encryption key identifier, value is the hash) and store the encrypted data id in the phone column.

Actually why are there 2 options.
Option 1 is simple.
Option 2 will allow you to change the encryption keys by decrypting the value, creating a new string with a hash from the new encryption key, and simply overwriting the string id in the phone field. It will also allow you to move encryption / decryption to a separate service with separate access to the database.

There is still a question with the search for encrypted data, if you have any thoughts - share :)
I will also not refuse criticism about the stack

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlexVWill, 2021-10-01
@AlexVWill

How to store encrypted data in a database?

It is not necessary to do this, because. if the data in the database is encrypted, then your database ceases to be such, and begins to be just a garbage dump with a bunch of encrypted data, search, sorting, selection, queries, etc. stop working.
You need to encrypt the database itself, not the data in it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question