---
schema_version: "1"
id: 3c1d366f247e59be4549931edf9284b1f4e3f08fa6301b49de2fdc5122d5840d
title: SHA512()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/references/encryption/mc-ampscript-reference-encryption-sha512.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-encryption/mc-ampscript-reference-encryption-sha512.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: adad4db58349d580a5afd29dc0b9a8b7790355c2a69e0f805b48ee7c1b9b6232
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# SHA512()

Converts a string to a 512-bit hexadecimal SHA-2 hash.

## Availability

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>✅ Yes</td>
  </tr>
</table>

## Syntax

```
SHA512(stringToConvert, charSet)
```

The `SHA512()` function has two parameters:

- `stringToConvert` (string): Required. The string to encode.
- `charSet` (string): The character set to use for encoding. Accepted values are `UTF-8` and `UTF-16`. The default value is `UTF-8`.

## Usage

To use this function, pass it a string.

```
%%=SHA512("This is a string of text.")=%%
```

The function outputs a SHA-2 hash of the provided string: `495a8104eef74ae73518705a8227555b596958343b4506860f1925a9cd7056e25473306a9d5ab841147d41cb7476dd965ab37f21bd379d625d42b40f18ef3356`

You can also generate the hash using UTF-16 encoding, as in this example.

```
%%=SHA512("This is a string of text.", "UTF-16")=%%
```

The function outputs a SHA-2 hash that uses UTF-16 encoding: `82fdb746ae8cc9a50b4da8e92706e41ef9d242a66c3d40a2a698124583f81769f35226679edbd2fa05c900a6c9ab8337b31f8fcc6f9f9cdfa56001899f758d8a`
