How to Hash Any String Using Salesforce Flow

How to Hash Any String Using Salesforce Flow

Record ids in Salesforce are unique identifiers that reference each record in the system. Therefore, they are essential for developers and administrators who work with Salesforce data. By understanding record ids, they can accurately reference and manipulate records within the system. In certain scenarios, it may be necessary to expose a record id within a public URL. For instance, if you create a public experience page with a screen flow, you can pass the record id from the URL. However, how secure is this? Anyone can change the id value from the URL. If they are lucky, they can access another Salesforce record. Therefore, you should use something that is much harder to guess. In this use case, you can use this custom action to hash any string value and use it instead of the record id.

What is Hashing?

Hashing is a process of transforming a string of data into a fixed-length sequence of characters, typically with a mathematical algorithm. The resulting hash value is unique and it is not possible to reverse it to obtain the original input. Hashing is widely used in computer security to protect sensitive data, such as passwords, by storing their hash values instead of the plain text. The hash function is one-way, meaning that it is not possible to determine the original input from its hash value. While you cannot decrypt hash values, they are not entirely foolproof and can be susceptible to brute force attacks. However, by using strong hashing algorithms and incorporating additional security measures, hash values can be an effective way to protect sensitive data.

About SHA256

SHA stands for Secure Hash Algorithm. SHA256 is a cryptographic hash function that generates a 256-bit hash value from any string of data. It is considered to be one of the most secure hashing algorithms available. SHA256 is a one-way function, meaning that it is not possible to reverse it to obtain the original input. This makes it a valuable tool for securing sensitive data, such as passwords and personal information. Overall, SHA256 is a reliable and secure method for hashing sensitive data.

Here are a few examples of where SHA256 is commonly used:

  • SSL/TLS certificates - It is used in SSL/TLS certificates to verify their authenticity and generate a unique fingerprint.
  • Bitcoin - SHA256 is used extensively in the Bitcoin protocol to generate and verify the digital signatures used in transactions and to mine new blocks.

Custom Flow Action to Hash Any String

Here is a custom action that can hash any string value. It uses the SHA256 hash function and generates a 64 characters long hash value. You can use this action for many purposes. For instance, you can hash the record id in order to generate a unique and impossible to guess id.

It is an Apex defined invocable action and it is available in any flow type that supports the action element.

How to Use the Component

1- Install the component using the installation links below.

2- Add a new action to your flow and search for Hash String, this is the name of the component that you installed.

Hash String action to hash any string

3- Provide any string that you want to hash. In this example, we are hashing the record id.

Hash Record Id

4- Add an Update Records element in order to save the hash value.

Save Hash Value
End of the Flow

As you can see, the action generates a long string value. Since the source (record id) is unique, it is safe to say that this new string is unique as well. Therefore, you can use it as a unique identifier of the record.

Result of the Flow

Installation Links

Use this link to install in production or developer edition environments.

Use this link to install in sandbox environments.

6 Comments

  1. Hi thanks so much for this! I have a question, when I have to add two Args: Secret Key and the params for the rest of the variables that creates the signature. How do add the Secret Key. Does that make sense?

  2. Can you please describe how I put the Hash Id in an URL?
    I have a use case where I want to replace my URL parameters (from recordfields) with a hash. How can I put the hash back in an URL?
    Thanks a lot.

1 Trackback / Pingback

  1. Sending One Time Password to Users to Improve Flow Security - Salesforce Time

Leave a Reply

Your email address will not be published.


*