> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kasoftware.com/llms.txt
> Use this file to discover all available pages before exploring further.

# encDecode

> 使用指定编码格式解码已编码的文件或数据字符串。

export const siteNameShort = "知行之桥";

解码已编码的文件或数据字符串。

## 必需的参数

必须为以下字段之一提供值，但不能同时提供：

* **data**：要解码的数据。
* **file**：要解码的文件。

## 可选的参数

* **format**：用于解码的格式。可用值为 **BASE64**、**HEX**、**HTML**、**JIS**、**QP**、**URL**、**UU** 和 **YENC**。默认值为 BASE64。
* **outfile**：用于存储解码数据的文件。**UU** 解码不支持此参数，因为它使用编码文件中存储的文件名。
* **outformat**：解码后数据使用的格式。可用值为 **RAW**、**BASE64** 和 **HEX**。默认值为 RAW。
* **encoding**：将解码后的字节数组转换为 RAW 格式时使用的编码。默认值为 UTF-8。

## 输出属性

* **decodeddata**：解码后的数据。
* **format**：用于解码的格式。
* **outfile**：如果为 **outfile** 指定了输入值，则此属性为包含解码数据的文件。

## 示例

以下 {siteNameShort}Script 代码放置在 [Script 端口](../../connectors/script) 中时，会从 **\[FilePath]** 处的输入文件读取 BASE64 编码的数据，对其进行解码，然后将文件推出：

```xml theme={null}
<!-- setting the file and encoding format for the input item -->
<arc:set attr="enc.file" value="[FilePath]" />
<arc:set attr="enc.format" value="BASE64" />

<arc:call op="encDecode" in="enc" out="result">
  <!-- setting the output file data to be the decoded data returned from the operation -->
  <arc:set attr="output.data">[result.decodeddata]</arc:set>
</arc:call>

<!-- setting the filename and pushing the file out -->
<arc:set attr="output.filename" value="[FileName]" />
<arc:push item="output" />
```

## 其他资源

以下文章是使用 encDecode 操作的实际用例：

* <a href="https://www.kasoftware.com/kb/2024/01/03/http-signature-auth.html" target="_blank">使用知行之桥EDI 系统的 HTTP 签名身份验证</a>
* <a href="https://www.kasoftware.com/kb/2024/01/02/get-token.html" target="_blank">如何获取用友 ERP 的动态 Token?</a>
