Calculate hash values
This article explains how to hash text and file data and calculate the hash value.
About hashing
Section titled “About hashing”Hashing is a technique that passes the original data through a hash function to generate a fixed-length string (a hash value).
Hashing the same data always produces the same hash value, and in practice, different data never produces the same hash value.
Because you can check whether two pieces of data are identical just by comparing their hash values, without comparing the data itself, hashing is used for purposes such as verifying that data hasn’t been tampered with.
Also, in practice, you can’t work out the original data from a hash value.
The action to use
Section titled “The action to use”The action used here is called “Hash text.”
Details of the “Hash text” action
Section titled “Details of the “Hash text” action”The action has the following parameters.
| Parameter | Value |
|---|---|
| Hash algorithm | The algorithm to use for hashing (SHA256 / SHA384 / SHA512) |
| Encoding | The encoding (character encoding) of the text to hash |
| Text to hash | The text to hash |

The hashing result is stored in the variable HashedText. The same text produces a different hash value if the encoding is different, so use the same encoding when you compare hash values (the default is “Unicode”).
Implement the action
Section titled “Implement the action”Add the sample flow by copying and pasting
Section titled “Add the sample flow by copying and pasting”As a sample, I prepared a flow that calculates a hash value from the specified text data.
Copy the following code and paste it into the Power Automate Desktop flow designer to add the actions.
SET HugeData TO $'''%'Data too large to transfer easily'%'''Cryptography.HashText HashAlgorithm: Cryptography.HashAlgorithm.SHA256 Encoding: Cryptography.EncryptionEncoding.UTF8 TextToHash: HugeData HashedText=> HashedTextImplement in Power Automate Desktop
Section titled “Implement in Power Automate Desktop”-
In “Search actions,” type “Hash text.”
-
Set the parameters as follows.
%HugeData%is the variable created on the first line of the sample flow (the “Set variable” action).Parameter Value Hash algorithm SHA256 Encoding UTF-8 Text to hash %HugeData% -
When you run the flow, the result of hashing the specified text data is stored in a variable.
Possible exceptions
Section titled “Possible exceptions”An error may occur when hashing runs.
We recommend adding error handling with an “On block error” block.