# utils

## decrypt

Decrypt text

\*\* Usage example:\*\*

```javascript
// to encrypt plaintext into ciphertext 
const encrypt = utils.encrypt('https://www.wikipedia.org');
log.info(encrypt); // will print b757ba2c2fc50fbb511d596816ca06c4fa56f4e98ce222f30bc58d5251ed635e

// to decrypt ciphertext and use it in script  
const decrypt = utils.decrypt(encrypt);
log.info(decrypt); // will print ENCRYPTED

web.init();
web.open(decrypt); // will open https://www.wikipedia.org

// to get original plaintext use getDecryptResult
const value = decrypt.getDecryptResult();
log.info(value); //will print https://www.wikipedia.org
```

**Parameters:**

| Name   | Type     | Description |
| ------ | -------- | ----------- |
| `text` | `String` | Text        |

**Returns:**

`Object` - DecryptResult Object with getDecryptResult method

## dnsResolve

Uses the DNS protocol to resolve a host name

**Parameters:**

| Name       | Type     | Description                                    |
| ---------- | -------- | ---------------------------------------------- |
| `hostname` | `String` | Host name to resolve.                          |
| `rrType`   | `String` | `optional` Resource record type. Default: 'A'. |

**Returns:**

`(Array.<String>|Object)` - Array or Object of resource records. The type and structure of individual results vary based on rrtype

## encrypt

Encrypt text

\*\* Usage example:\*\*

```javascript
// to encrypt plaintext into ciphertext 
const encrypt = utils.encrypt('https://www.wikipedia.org');
log.info(encrypt); // will print b757ba2c2fc50fbb511d596816ca06c4fa56f4e98ce222f30bc58d5251ed635e

// to decrypt ciphertext and use it in script  
const decrypt = utils.decrypt(encrypt);
log.info(decrypt); // will print ENCRYPTED

web.init();
web.open(decrypt); // will open https://www.wikipedia.org

// to get original plaintext use getDecryptResult
const value = decrypt.getDecryptResult();
log.info(value); //will print https://www.wikipedia.org
```

**Parameters:**

| Name   | Type     | Description |
| ------ | -------- | ----------- |
| `text` | `String` | Text        |

**Returns:**

`String` - Encrypted text

## pause

Pause test execution for the given amount of milliseconds.

**Parameters:**

| Name | Type     | Description                              |
| ---- | -------- | ---------------------------------------- |
| `ms` | `Number` | Milliseconds to pause the execution for. |

## readCsv

Reads data from csv file

**Parameters:**

| Name       | Type     | Description                                             |
| ---------- | -------- | ------------------------------------------------------- |
| `filePath` | `String` | Absolute path to file                                   |
| `options`  | `Object` | `optional` [Options](https://csv.js.org/parse/options/) |

## readXlsx

Reads data from Xlsx file

**Parameters:**

| Name       | Type     | Description           |
| ---------- | -------- | --------------------- |
| `filePath` | `String` | Absolute path to file |

**Returns:**

`Array` - Array of xlsx data

## transaction

Opens new transaction.

The transaction will persist untill a new one is opened. Transaction names must be unique.

**Parameters:**

| Name   | Type     | Description           |
| ------ | -------- | --------------------- |
| `name` | `String` | The transaction name. |

## writeCsv

Writes data into csv file

**Parameters:**

| Name       | Type     | Description                                                                                    |
| ---------- | -------- | ---------------------------------------------------------------------------------------------- |
| `filePath` | `String` | Absolute path to file                                                                          |
| `data`     | `Array`  | CSV data in format \[{column\_name\_1: 'foo', column\_name\_2: 'bar'}]                         |
| `options`  | `Object` | `optional` [Options](https://github.com/anton-bot/objects-to-csv#async-todiskfilename-options) |

## xmlToJson

Parse XML data to JS object

**Parameters:**

| Name         | Type                | Description                                                                                                |
| ------------ | ------------------- | ---------------------------------------------------------------------------------------------------------- |
| `xmlDataStr` | `string`\|`Buffer`  | Like                                                                                                       |
| `options`    | `boolean`\|`Object` | [Options](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md) |


---

# Agent Instructions: 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:

```
GET https://docs.oxygenhq.org/download-installation-start/modules/module-utils.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
