defrex / django-encrypted-fields

This is a collection of Django Model Field classes that are encrypted using Keyczar.
MIT License
193 stars 60 forks source link

Encrypting Previously entered data #10

Closed ghost closed 9 years ago

ghost commented 9 years ago

Thanks for making this. Worked like a charm, but I noticed an unexpected issue when i started using the app. I had a previously unencrypted CharField of first_name and last_name' I installed django-encrypted field and updated my model using the EncryptedCharField. When I enter new data, everything appears as I expected: The view shows me the unencrypted first_name and last_name while the database shows the fields encrypted.

However, with the data that was already entered, the view shows the encrypted fields as they appear on the database - basically gibberish. Is there anything that can be done about this? I'm working with a local version, but want to update the deployed version with the encrypted fields, but I'm a bit concerned that I would freak out users because of the above issue.

defrex commented 9 years ago

The encrypted fields assume that the data in the db is encrypted. So if it pulls some plaintext out of the database, it will be treated as cyphertext, which will turn it into gidderish.

I would recommend a data-migration strategy. There would be three migrations needed.

After running those, you should have all your old data safely encrypted in the new field.