> ## 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.

# encEncode

> 使用指定編碼格式（如 BASE64、HEX 或 SHA）編碼檔案或資料字串。

export const siteNameShort = "知行之橋";

用指定編碼格式編碼檔案或資料字串。

## 必需的參數

必須為以下欄位之一提供值，但不能同時提供：

* **data**：要編碼的資料。
* **file**：要編碼的檔案。

## 可選的參數

* **format**：用於編碼的格式。可用值為 **BASE64**、**HEX**、**HMAC**、**HTML**、**JIS**、**MD5**、**QP**、**SHA1**、**URL**、**UU** 和 **YENC**。預設值為 BASE64。
* **outfile**：用於儲存編碼資料的檔案。
* **outformat**：編碼後資料使用的格式。可用值為 **RAW**、**BASE64** 和 **HEX**。預設值為 RAW。
* **encoding**：編碼前將資料轉換為位元組陣列時使用的編碼。預設值為 UTF-8。

## 輸出屬性

* **encodeddata**：編碼後的資料。
* **format**：用於編碼的格式。
* **outfile**：如果為 **outfile** 指定了輸入值，則此屬性為包含編碼資料的檔案。

## 範例

以下 ArcScript 程式碼放置在 [Script 端口](../../connectors/script) 中時，會從 **\[FilePath]** 處的輸入檔案讀取資料，使用預設 BASE64 格式對其進行編碼，然後將檔案推出：

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

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

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

## 其他資源

以下文章是使用 encEncode 操作的實際用例：

* <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>
