Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs
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 ...
Tarachand Karwal's user avatar
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....
Mariia Illarionova's user avatar
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 */ ...
cropredy's user avatar
  • 71.7k
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 ...
Pranay Jaiswal's user avatar
8 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 ...
Eliot Harper's user avatar
  • 16.6k
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 ...
Adrian Larson's user avatar
  • 150k
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 (...
cropredy's user avatar
  • 71.7k
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 ...
Lukas Lunow's user avatar
  • 21.6k
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 ...
Oleh Berehovskyi's user avatar
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 ...
sfdcfox's user avatar
  • 493k
6 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&...
Adam Spriggs's user avatar
  • 30.7k
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,...
Jason Clark's user avatar
  • 11.9k
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 ...
David Reed's user avatar
  • 93.1k
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 ...
jmdohn's user avatar
  • 1,064
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 ...
Adam Spriggs's user avatar
  • 30.7k
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 ...
sfdcfox's user avatar
  • 493k
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.
Oleksandr Berehovskyi's user avatar
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 ...
David Reed's user avatar
  • 93.1k
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, ...
cropredy's user avatar
  • 71.7k
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) ...
Phil W's user avatar
  • 36.6k
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&...
Derek F's user avatar
  • 62k
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 ...
Macca's user avatar
  • 8,236
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'...
David Reed's user avatar
  • 93.1k
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 "...
Sebastian Kessel's user avatar
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 ...
synotna's user avatar
  • 41
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)
Christian Szandor Knapp's user avatar
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 ...
sfdcfox's user avatar
  • 493k
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 = '...
Abhishek Daware's user avatar
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 ...
Travis Naughton's user avatar
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 ...
sfdcfox's user avatar
  • 493k

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