24
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 */
...
9
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:
AMPscript is not currently ...
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
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 ...
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 (...
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 ...
7
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&...
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
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.
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 ...
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,...
6
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 ...
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 ...
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 ...
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 ...
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 ...
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, ...
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) ...
5
votes
Accepted
How to encrypt text in apex using sha512 algorighm?
There is a difference between hashing (which is what the SHA512 algroithm does) and encrypting.
Hashing
A hash is a one-way function (or it's supposed to be). You put data in, you get a "hash&...
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 ...
5
votes
Implementing encryption within Aura Component
This console is accessed by our business team to work with customer cases. As we are including all data in the URL, I am trying to implement encryption on one of the URL parameters that holds customer'...
5
votes
Accepted
Encrypt in Marketing Cloud - Decrypt in Salesforce
Finally I found a solution.
MKCloud AMPScript's default AES implementation is based on a 256 bit key size, CBC with 16 byte block size, and PKCS7 with 1000 iterations.
The derived Key generation is ...
4
votes
Accepted
How Does salesforce stores passwords ? which algorithm / mechanism uses saelsforce to store password?
I suppose one of these https://trust.salesforce.com/en/compliance/ would cover your requirement at least from business perspective (i.e. without disclosing technical details)
4
votes
EncryptSymmetric AMPScript AES
It is possible to get it working with AES too
The trick is block size 16, key size 32, pbkdf2 with 1000 iterations and padding pkcs7
import base64
from pprint import pprint
from Cryptodome.Cipher ...
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 ...
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
What's the best practice for encryption key storage
You'll want to read Secure Coding Storing Secrets. This is what the post has to say:
The Apex crypto class provides algorithms for creating digests, MACs, signatures and AES encryption. When using ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
encryption × 250apex × 92
marketing-cloud × 46
crypto × 42
platform-encryption × 39
shield-encryption × 23
security × 20
decrypt × 19
ampscript × 16
shield × 12
rest-api × 9
managed-package × 9
visualforce × 8
integration × 8
soql × 7
javascript × 7
api × 5
dataextensions × 5
custom-field × 5
customsetting × 5
email × 4
custom-object × 4
controller × 4
ssjs × 4
passwords × 4