23 votes
Accepted

SHA1 Hash Results

You Should use this String shasign = EncodingUtil.convertToHex(Crypto.generateDigest('SHA1',Blob.valueOf(Your String))); Clarification -: base64Encode will simply convert a Blob to an unencoded ...
17 votes

Way to see all encrypted fields in Salesforce?

It can be done through apex execution, not through SOQL: for (Schema.SObjectType object_i : Schema.getGlobalDescribe().values()) { for (Schema.SObjectField field_i : object_i.getDescribe().fields....
13 votes

What is the performance penalty for Deterministic Platform Encryption?

I encrypted a few PII fields on Contact: and ran this script to insert and then query back 200 Contacts: delete [select Id from Contact where createddate = TODAY]; /* test cost of encryption */ ...
  • 63.8k
8 votes
Accepted

How can I mask sensitive data in sandbox?

You can use SandboxPostCopy interface that allows you run an Apex class as soon as sandbox is refreshed. Use that class to run a batch class that makes your data encrypted. I have implemented ...
7 votes
Accepted

How will Salesforce's move to SHA-256 for certs impact Mobile SDK users?

My understanding is that it will not impact apps built using the Mobile SDK 3.0 as it already supports SHA-256 in its libraries. However, you still need devices/ browsers meet the compatibility ...
7 votes

Is this an expected behavior? Encrypted Text visibility

It is expected that you should be able to see it. From Classic Encryption for Custom Fields: Encrypted field data is not always masked in the debug log. Encrypted field data is masked if the ...
  • 144k
7 votes
Accepted

Deploy V42 (beta) Deterministic Platform Encryption

At least as of V42, you are out-of-luck. The V42 Metadata API does not provide any support for the distinction between probabilistic encryption (introduced in V34) and deterministic encryption (...
  • 63.8k
7 votes
Accepted

Has anyone enabled Transparent Data Encryption (TDE) in Marketing Cloud?

TDE is, as EazyE also mentions, a paid feature. You should reach out to your Account Executive to have it enabled, but it will come at a price. Do observe, if you accept the cost, it might not be ...
  • 17.7k
7 votes

How can I encrypt a string in Apex in a way that an external system can decrypt using C#?

David is absolutely right and I'd like to add some extra information and provide code examples regarding Apex-encryption/C#-decryption. To encrypt some String in Apex using the AES256-CBC algorithm ...
6 votes
Accepted

Encryption and Decryption in apex Salesforce Using Crypto Class

The following code works in my org. Blob key = Crypto.generateAesKey(256); Blob source = Blob.valueOf('Hello World'); Blob encrypted = Crypto.encryptWithManagedIV('AES256', key, source); String ...
  • 445k
6 votes

How to encrypt text in apex using sha512 algorighm?

As @DerekF pointed out in his comment, you are conflating Hashing and Encryption. SHA-512 is the 512-bit digest version of the SHA-2 hashing function. Per Wikipedia, a cryptographic hashing function,...
  • 11.1k
5 votes
Accepted

Integer Array to Base64 String

String.fromCharArray is going to create a UTF-8 encoded string, which will alter the bytes in the stream. For example, 242 will be encoded as two bytes instead of one. Any value outside 0-127 will be ...
  • 445k
5 votes
Accepted

Lightning Components and Encrypted Fields

Modify the controller to be the following and encrypted data will be supported. Note: This can easily be supported with dynamic queries and sObject describes to be scalable, however, due to the ...
  • 1,014
5 votes

EncryptSymmetric AMPScript AES

I have decrypted SFMC encrypted strings in C# outside of the platform. Credit for the method goes to Pato Sapir on Github for his et-encrypt-decrypt solution. You should be able to decrypt the ...
  • 28.3k
5 votes
Accepted

Creating an encrypted text field through metadata deployment - invalid length, maximum is: 255

Maximum length of text encrypted field is 175. Salesforce just shows incorrect error message you can read it here Are limited to 175 characters because of the encryption algorithm.
5 votes
Accepted

Prevent Duplicates using unique key

BUT can I rely on it ? Is there a possibility that 2 records with different keys would generate the same hash ? Yes, there is. There must be, because you're compressing more than 256 bits of data ...
  • 88.2k
5 votes

Search affected by encryption?

Deterministic Encryption considerations doc is pretty clear on this for compound fields like Contact.Name (Account.Name is not a compound field) Compound Fields Even with deterministic encryption, ...
  • 63.8k
5 votes
Accepted

SSJS equivalent of DecryptSymmetric

Here's what I use in SSJS. You'd need to use your own password, vector and salt, obviously. Encrypt function encryptString(decStr) { Variable.SetValue("decStr", decStr); </script&...
  • 28.3k
5 votes

SSJS equivalent of DecryptSymmetric

Adam's answer will work for CloudPages, but not for a Script Activity in an Automation, as the following error will be returned when validating the Script Activity: AMP Script is not currently ...
  • 15.9k
5 votes
Accepted

Obfuscate or Encrypt LWC Source Code

You can't get into the compilation and delivery phases for LWC and therefore cannot apply your own obfuscation. It seems clear to me that you simply need to ensure that the client code (i.e. the LWC) ...
  • 28.7k
5 votes

Populate data extension with SH-256 encrypted email addresses

I'd recommend not taking this approach for a number of reasons: SSJS doesn't support SHA256 hashing, so you'll need to switch between SSJS and AMPScript that has SHA256 support. This gives rise to a ...
  • 7,846
5 votes
Accepted

Shield encrypted field, unencrypted results?

Shield Platform Encryption provides encryption for data at rest. While it does impact your ability to interact with the field data in specific ways primarily around sorting and aggregation (see ...
  • 88.2k
4 votes

Can we use encrypted fields in Report Filters with Platform Encryption

Unfortunately no. Per this doc: Considerations for Using Platform Encryption With Fields https://help.salesforce.com/HTViewHelpDoc?id=security_pe_considerations_all_fields.htm&language=en_US ...
  • 53.3k
4 votes

Compare Encryption: Apex Differs From Java?

You don't want to turn your results into a base64 string - it's pretty hard to get a readable string after you do that. Instead, just call the Blob.toString() method: system.debug('This is ...
4 votes
Accepted

Error while encrypting

Check the Blob size that comes back from: Blob PrivateKey = EncodingUtil.base64Decode('Secretkey'); It should be 16 bytes. With the sample code you have the length is only 6, but I suspect that is ...
4 votes

Platform Encryption vs. FLS

Platform Encryption will go further than just preventing the users from seeing data, it will also encrypt the fields at the database level. For example, you can't even issue a SoQL query doing an "...
4 votes

Two-Way SSL vs Crypto Class

You use SSL to secure data in motion, and the Crypto class to secure data at rest. Generally speaking, you want to secure communication between Salesforce and some other system, you use SSL; you can ...
  • 445k
4 votes

How to generate a 32 byte private key?

Above error is thrown because the private key is not 32 bytes. The expected and actual private key byte calculation is mismatching. Recommended approach to resolve this String algorithmName = '...
4 votes

encrypt email address in a data extension

Little late on the answer but I've been working on this recently and someone might find this information useful. If you are looking to do an encryption on data once it is inside Marketing Cloud the ...
4 votes
Accepted

Why can I still see encrypted File and Attachment?

Shield Platform Encryption encrypts your data at rest, on the Salesforce server. It helps you to meet compliance requirements for your industry. Salesforce Shield is not intended to protect your data ...
  • 88.2k

Only top scored, non community-wiki answers of a minimum length are eligible