To protect sensitive data - such as HIPAA info
-
3Not currently. This wouldn't be hard to implement - but the process by which you decide who can decrypt it would get very hairy. Can you edit your question to explain how you want to determine who can view decrypted data?– Jon G - Megaphone TechApr 17, 2015 at 20:48
-
For starters, the purpose would be to encrypt fields when stored so an unauthorized access directly to the database would not be able to see the encrypted database. As to Civi users, I assume we would use existing permissions to restrict access.– Dave TApr 24, 2015 at 1:36
-
You can restrict access by custom field group, not custom field - but you can have a single field in a group. So you're suggesting that any custom field groups that are subject to an ACL should be encrypted at rest, and accessible to folks in the ACL group? Not currently an option, but an excellent suggestion for improvement.– Jon G - Megaphone TechApr 24, 2015 at 4:35
-
Yes, that would work. I am not a coder but is it safe to say that Lobo's recommendation could be employed with the custom field group ACL solution?– Dave TApr 25, 2015 at 22:50
-
I believe so, yes.– Jon G - Megaphone TechApr 26, 2015 at 1:08
3 Answers
You should be able to use the functions in:
CRM/Utils/Crypt.php
to do symmetric encryption/decryption of the fields. Password related fields in the CiviCRM db are encrypted. As Lesley mentions, there are two aspects to this problem. Encrypting data, and restricting access to the data to a certain class of users
Do you want just one field encrypted or a group of fields (if you're dealing w/HIPAA data, probably it is more than one, right?) Create custom fields where the 'Type' is, say, 'HIPAA' (you can create this subtype by subtyping your basic object, whether it is Activities, Campaigns, or Contacts). From there, you'd need to add a hook/code to encrypt fields where the Type == HIPAA.. You'd need to also determine which user type(s) (Admin?) should be able to see unencrypted values and handle that.
We were recently asked to 'Encrypt one CiviCRM custom field' for one of our clients who uses Webform CiviCRM module as a GUI to view/edit/add custom field values to CiviCRM for their clients.
I ended up leveraging Drupal Encrypt module to not just encrypt the values stored on the Drupal side (in the Webform Submission) but also to encrypt the values stored on the CiviCRM side.
Using Webform CiviCRM module to handle view/edit/add custom field values means a variety of Drupal access permissions are available to control which user can see what.
Example: a:6:{s:4:"text";s:128:"JA/qWZ50z61GS7hA3mvXSyKSHjoOdxAnr+LttK8/ZIpLNOl1yTBY6+xPN0B9T08wqdat5Rvdbois1EVXrPXYA7OZO6ja08hW8NjNk1Fsn47TBJuWGWKpEC+k0cCjYAiV";s:6:"method";s:14:"mcrypt_aes_cbc";s:12:"key_provider";s:15:"drupal_variable";s:7:"options";a:1:{s:6:"base64";b:1;}s:15:"method_settings";s:0:"";s:17:"provider_settings";a:1:{s:6:"method";s:13:"base64_decode";}}
If you think this may be useful, feel free to give it a try and let me know what you think. The code lives here -> https://github.com/KarinG/webform_deur_encrypt