function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Yuvraj GanesanYuvraj Ganesan 

How to encrypt Files and Attachment?

I am using Dev instance where Platform Encryption is enabled. When attaching the file to relevant record, it will encrypt the files before storing into Salesforce Db. But that attachment file is still visible to another user.
My Question is how to show encrypted the uploaded files attachment to specific user who dont have "View Encrypted Data" permission. 

Attachment Files must be seen in plain text only who have 'View Encrypted Data' Permission.
scottbcovertscottbcovert
Hi Yuvraj,

I admittedly don't have too much personal experience utilizing encryption within Salesforce, but I took a look at the documentation and it seems file and attachment encryption is separate from the 'view encrypted data' permission, which applies to encrypted field data. Thus, when it comes to files and attachments users who have read access to the file will be able to view it normally, regardless of their encryption permission settings (see the note marked 'Important' in the link below).

https://help.salesforce.com/HTViewHelpDoc?id=security_pe_enable_files_attachments.htm&language=en_US

I believe it's possible to roll your own custom solution for encryption/decryption of attachments on a per user basis though; here is a link to get you started.

https://developer.salesforce.com/forums/?id=906F000000093iAIAQ

Please note though that the provided code does not perform any security check to verify the running user has authorization to use the stored key; this is obviously critical so you wouldn't want to copy/paste this solution completely as-is.