概要
傳回輸入字串的base64表示法。
語法
base64(<inputString>)
描述
函 base64() 式會傳回輸入字串的 base64 表示法。 傳遞編碼為base64的數據可減少傳入數據的錯誤,特別是當不同的工具需要不同的逸出字元時。
範例
範例 1 - 將字串轉換為 base64
組態會使用 base64() 函式轉換基本字串值。
# base64.example.1.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo 'abc' in base64
type: Microsoft.DSC.Debug/Echo
properties:
output: "[base64('abc')]"
dsc --file base64.example.1.dsc.config.yaml config get
results:
- name: Echo 'abc' in base64
type: Microsoft.DSC.Debug/Echo
result:
actualState:
output: YWJj
messages: []
hadErrors: false
範例 2 - 將串連字串轉換為 base64
組態會使用函式內的 base64()concat () 函式,在傳回 base64 表示法之前,先將字串 a、 b和 c 合併成 abc 。
# base64.example.2.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Echo concatenated 'a', 'b', 'c' in base64
type: Microsoft.DSC.Debug/Echo
properties:
output: "[base64(concat('a', 'b', 'c'))]"
dsc --file base64.example.2.dsc.config.yaml config get
results:
- name: Echo concatenated 'a', 'b', 'c' in base64
type: Microsoft.DSC.Debug/Echo
result:
actualState:
output: YWJj
messages: []
hadErrors: false
參數
inputString
函 base64() 式需要單一字串作為輸入。 函式會將值轉換成base64表示法。 如果值不是字串,DSC 會在驗證組態檔時引發錯誤。
Type: string
Required: true
MinimumCount: 1
MaximumCount: 1
輸出
函 base64() 式會傳回 inputString 值的 base64 表示法。
Type: string