> For the complete documentation index, see [llms.txt](https://docs.frends.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frends.com/tasks/tasks/cryptography/generatehash.md).

# GenerateHash

Task version: 2.0.0

Required Frends version: 5.7+

Required .NET version: 8.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.Cryptography>

## Task Parameters

{% tabs %}
{% tab title="Input" %}

| Name                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| HashFunction : `Function` | <p>Generates input string to chosen HashAlgorithm type.</p><p>Possible values:</p><ul><li><code>MD5</code>: Generates input string to chosen HashAlgorithm type.</li><li><code>SHA1</code>: Generates input string to chosen HashAlgorithm type.</li><li><code>SHA256</code>: Generates input string to chosen HashAlgorithm type.</li><li><code>SHA384</code>: Generates input string to chosen HashAlgorithm type.</li><li><code>SHA512</code>: Generates input string to chosen HashAlgorithm type.</li><li><code>HMACSHA256</code>: Generates input string to chosen HashAlgorithm type.</li><li><code>HMACSHA512</code>: Generates input string to chosen HashAlgorithm type.</li></ul><p><br>Default: <code>0</code><br>Example: <code>MD5</code></p> |
| InputString : `String`    | <p>Input string to be hashed.</p><p><br>Default: <code>-</code><br>Example: <code>foo</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| 🗝HashKey : `String`      | <p>HashKey when using HMACSHA256 or HMACSHA512 HashAlgorithm type.</p><p><br>Default: <code>-</code><br>Example: <code>foobar</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| {% endtab %}              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

{% tab title="Options" %}

| Name                             | Description                                                                                                                                                                                                                                    |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ThrowErrorOnFailure : `Boolean`  | <p>Throw an exception if the task fails.</p><p>If set to false, the task returns an error result instead.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                               |
| ErrorMessageOnFailure : `String` | <p>Custom error message to use when an error occurs.</p><p>Leave empty to use the original exception message.</p><p><br>Default: <code>-</code><br>Example: <code>GenerateHash encountered an error while hashing the input string.</code></p> |
| {% endtab %}                     |                                                                                                                                                                                                                                                |
| {% endtabs %}                    |                                                                                                                                                                                                                                                |

## Task Result

| Name                | Description                                                                                                                                                                                                               |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success : `Boolean` | <p>Indicates whether the operation was successful.<br>Example: <code>true</code></p>                                                                                                                                      |
| Error : `Error`     | <p>Error information when the operation fails and ThrowErrorOnFailure is false.<br>Example: <code>{ Message = "GenerateHash failed: input string cannot be null.", AdditionalInfo = "NullReferenceException" }</code></p> |
| Hash : `String`     | <p>HashResult.<br>Example: <code>8843d7f92416611de9ebb963fy4ce281v5932878</code></p>                                                                                                                                      |

## Task Changelog

Changelog for Task Frends.Cryptography.GenerateHash.

### \[2.0.0] - 2026-07-20

#### Changed

* The task now targets .NET 8.
* Added an **Options** parameter to control error handling: you can choose whether the task throws an exception on failure (`ThrowErrorOnFailure`) or returns an error result with details (`ErrorMessageOnFailure`).
* The result now includes a `Success` flag and an `Error` object with details when the hash computation fails.
* **Breaking change**: The `GenerateHash` method signature has been updated to include the new `Options` and `CancellationToken` parameters.

### \[1.0.0] - 2022-08-11

#### Added

* Initial implementation


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.frends.com/tasks/tasks/cryptography/generatehash.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
