---
name: "base64ToRaw"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "conversion"
---

## base64ToRaw

> [VERSION] @ray-js/panel-sdk >= 1.0.0

> 💡 Commonly used for DP data decoding conversion, restoring Base64-formatted raw DP values to a hexadecimal string.

### Description

Convert a Base64-encoded string to a hexadecimal raw string

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `value` | `string` | Yes | A Base64-encoded string |

### Return Value

Type: `string`

The corresponding hexadecimal raw string, two characters per byte

### Examples

#### Basic usage

```ts
import { utils } from '@ray-js/panel-sdk';

const { base64ToRaw } = utils;

base64ToRaw('SGVsbG8='); // '48656c6c6f'
base64ToRaw('/wA=');     // 'ff00'
```

---
name: "rawToBase64"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "conversion"
---
## rawToBase64

> [VERSION] @ray-js/panel-sdk >= 1.0.0

> 💡 Commonly used for DP data encoding conversion, converting raw DP values to Base64 for transmission.

### Description

Convert a hexadecimal raw string to a Base64-encoded string

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `value` | `string` | Yes | A hexadecimal raw string whose length must be even |

### Return Value

None


### Examples

#### Basic usage

```ts
import { utils } from '@ray-js/panel-sdk';

const { rawToBase64 } = utils;

rawToBase64('48656c6c6f'); // 'SGVsbG8='
rawToBase64('ff00');       // '/wA='
rawToBase64('f');          // '' (odd length returns empty string)
```

---
name: "hexToBinary"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "conversion"
---
## hexToBinary

> [VERSION] @ray-js/panel-sdk >= 1.0.0

### Description

Convert a hexadecimal string to a binary string

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `value` | `string` | Yes | Hexadecimal string |

### Return Value

None


### Examples

#### Basic usage

```ts
import { utils } from '@ray-js/panel-sdk';

const { hexToBinary } = utils;

hexToBinary('ff'); // '11111111'
hexToBinary('0a'); // '1010'
hexToBinary('1');  // '1'
```

---
name: "generateDpStrStep"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "conversion"
---
## generateDpStrStep

> [VERSION] @ray-js/panel-sdk >= 1.0.0

> 💡 Internally uses a generator to read the hex string segment by segment. By default it reads 2 characters (1 byte) at a time; configurable via parameters.

### Description

Create a step-wise parser for raw or string DPs

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `dpStr` | `string` | Yes | The DP hexadecimal string to parse |

### Return Value

Type: `(num: number, type: "string" \| "number") => __object`

A step parser function; each call returns the next parsed segment as { value, done }

### Examples

#### Basic usage

```ts
import { utils } from '@ray-js/panel-sdk';

const { generateDpStrStep } = utils;

const step = generateDpStrStep('3264');
const val1 = step().value;  // 50  (0x32)
const val2 = step(2).value; // 100 (0x64)
```
