> ## 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** 指定了輸入值，則此屬性為包含解碼資料的檔案。

## 範例

以下 ArcScript 程式碼放置在 [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>
