# Crypto (/docs/products/dash-dots/reference/dash-api/crypto)

## `dash.crypto.sha256`

```ts
dash.crypto.sha256(data: CryptoInput, options?: CryptoOutputOptions, callOptions?: CallOptions): DashRequest<string>
```

The SHA-256 hash of `data`, in hex unless you ask for `{ as: 'base64' }`. Pass text, or `{ base64 }` for binary data such as a file's contents.

Types: [`CryptoInput`](/docs/products/dash-dots/reference/dash-api/crypto#cryptoinput), [`CryptoOutputOptions`](/docs/products/dash-dots/reference/dash-api/crypto#cryptooutputoptions)

## `dash.crypto.sha512`

```ts
dash.crypto.sha512(data: CryptoInput, options?: CryptoOutputOptions, callOptions?: CallOptions): DashRequest<string>
```

The SHA-512 hash of `data`, in hex unless you ask for `{ as: 'base64' }`. Pass text, or `{ base64 }` for binary data.

Types: [`CryptoInput`](/docs/products/dash-dots/reference/dash-api/crypto#cryptoinput), [`CryptoOutputOptions`](/docs/products/dash-dots/reference/dash-api/crypto#cryptooutputoptions)

## `dash.crypto.hmac`

```ts
dash.crypto.hmac(options: HmacOptions, callOptions?: CallOptions): DashRequest<string>
```

Signs `data` with `key`, as HMAC-SHA256 or HMAC-SHA512, such as `hmac({ algorithm: 'sha256', key, data })`.

Types: [`HmacOptions`](/docs/products/dash-dots/reference/dash-api/crypto#hmacoptions)

## `dash.crypto.randomBytes`

```ts
dash.crypto.randomBytes(count: number, options?: CryptoOutputOptions, callOptions?: CallOptions): DashRequest<string>
```

`count` secure random bytes, from 1 to 1024.

Types: [`CryptoOutputOptions`](/docs/products/dash-dots/reference/dash-api/crypto#cryptooutputoptions)

## `dash.crypto.randomUUID`

```ts
dash.crypto.randomUUID(callOptions?: CallOptions): DashRequest<string>
```

A random version 4 UUID, such as "3f0e5c3a-6d1b-4c8e-9a2f-1b7d4e6a9c05".

## Types

### `CryptoInput`

Text is read as UTF-8. Binary data, such as a file's contents, comes as base64.

```ts
type CryptoInput = string | { base64: string };
```

### `CryptoOutputOptions`

Hex by default.

| Field           | Type                | What it is |
| --------------- | ------------------- | ---------- |
| `as` (optional) | `'hex' \| 'base64'` |            |

### `HmacAlgorithm`

```ts
type HmacAlgorithm = 'sha256' | 'sha512';
```

### `HmacOptions`

Also has the fields of [`CryptoOutputOptions`](/docs/products/dash-dots/reference/dash-api/crypto#cryptooutputoptions).

| Field       | Type                                                                                | What it is |
| ----------- | ----------------------------------------------------------------------------------- | ---------- |
| `algorithm` | [`HmacAlgorithm`](/docs/products/dash-dots/reference/dash-api/crypto#hmacalgorithm) |            |
| `key`       | [`CryptoInput`](/docs/products/dash-dots/reference/dash-api/crypto#cryptoinput)     |            |
| `data`      | [`CryptoInput`](/docs/products/dash-dots/reference/dash-api/crypto#cryptoinput)     |            |
