I have implemented Encrypt module in our site to make the fields encrypted while storing into the database. After installation of this module the new contents added are properly encrypted into the database and while editing the contents all the fields are showing. But our site had some more amount of data prior installing the encrypt module. Now those contents are not showing any data on edit panel. So, please tell me how can I encrypt those old contents in our site.

Comments

lizzjoy’s picture

Project: Drupal Association Project(s) » Encrypt
Component: Site organization » Code
Category: Task » Support request
rlhawk’s picture

Are you using Field Encrypt to manage which fields to encrypt? That module should handle encrypting any existing data for the chosen field.

rlhawk’s picture

Title: Encryption Problem » Existing data not encrypted when field is selected for encryption

Changed title to be more descriptive. If the problem is related to Field Encrypt, I'll move the issue there, but I'll wait to hear back from the poster.

souvikda’s picture

I am using Encrypt module
https://www.drupal.org/project/encrypt

with aes encryption.

rlhawk’s picture

Right, but Encrypt just provides an API. What are you actually using to employ that API? Did you write custom code or are you using a contributed module?

souvikda’s picture

Encrypt Form API contributed module has been used for encryption.

rlhawk’s picture

Project: Encrypt » Encrypt Form API
Version: 7.x-1.x-dev » 7.x-2.x-dev

Moved to Encrypt Form API.

rlhawk’s picture

Encrypt Form API only encrypts when a form is submitted, so it doesn't encrypt existing data. You'll need to handle that yourself.

souvikda’s picture

we have used Field Encrypt module but it is not encrypting older data. Is there is some way to write custom script to encrypt the older data ?

rlhawk’s picture

Project: Encrypt Form API » Field Encryption
Version: 7.x-2.x-dev » 7.x-1.x-dev

OK, so you are using Field Encryption. That module should encrypt your existing data automatically when you choose a field to encrypt. If you somehow have unencrypted data, though, you can certainly write a custom script to load each entity and detect if the data for a field is encrypted, and if not, encrypt it and save.

rlhawk’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta2
souvikda’s picture

can you help me with some custom scripts to do that.

rlhawk’s picture

souvikda, did you find a solution? If not, a general outline for the script would be to load all entities in batches, cycling through one at a time looking for an indication of encryption (perhaps through a regular expression); if the field you're processing is not encrypted, call encrypt() with the data and save the entity. I recommend using an entity field wrapper for the getting and setting.

jnicola’s picture

So I've run into a similar issue to this, but not via the same path this user took.

Using this module in a standard fashion where you enable it on a field either earl in the process, or at a distinct point on a specific site works without issue. However, sites are more dynamic than this. What if you have a live site collecting unencrypted data and you're working towards deploying encryption.

Features is a standard method for deployment, and when I tested deployment with features, features updated the field in a fashion that never actually triggered field_encrypt_do_encrypt().

Our workaround for this is that I've written a custom batch enable module that batch enables encryption on the modules instead of relying on features to deploy. This in turn triggers field_encrypt_do_encrypt() properly and all fields wind up encrypted.

This doesn't really help define the solution much, but may shed light on some of the problem occurring for some users?

deciphered’s picture

@jnicola, I've opened a new issue with the comments you've made, as I believe it's probably a separate issue to the originally reported issue: #2703415: Feature deployed fields not triggering encryption.

deciphered’s picture

Status: Active » Postponed (maintainer needs more info)

Original issue from @souvikda will require more information, namely steps to reproduce the issue, before I can attempt to resolve said issue.

ptmkenny’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Drupal 7 is EOL (end of life) so 7.x issues are now being closed.