Condividi tramite


base64

Riepilogo

Restituisce la rappresentazione base64 di una stringa di input.

Sintassi

base64(<inputString>)

Descrizione

La base64() funzione restituisce la rappresentazione base64 di una stringa di input. Il passaggio dei dati codificati come base64 può ridurre gli errori nel passaggio dei dati, soprattutto quando diversi strumenti richiedono caratteri di escape diversi.

Esempio

Esempio 1 - Convertire una stringa in base64

La configurazione converte un valore stringa di base con la base64() funzione.

# 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

Esempio 2 : convertire una stringa concatenata in base64

La configurazione usa la funzione concat() all'interno della base64() funzione per combinare le stringhe a, be c in abc prima di restituire la rappresentazione base64.

# 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

Parametri

inputString

La base64() funzione prevede una singola stringa come input. La funzione converte il valore in una rappresentazione base64. Se il valore non è una stringa, DSC genera un errore durante la convalida del documento di configurazione.

Type:         string
Required:     true
MinimumCount: 1
MaximumCount: 1

Output

La base64() funzione restituisce la rappresentazione base64 del valore inputString .

Type: string