Skip to main content
European CommissionEBSI European Blockchain

Encoding

Commands for encoding and decoding data in various formats.

compute decodeJWT <jwt>

Command to decode a JWT. It's also possible to load it from the saved variables by referencing its name.

Parameters:

  • jwt: JWT to decode.

Examples:

compute decodeJWT eyJ0e...
compute decodeJWT myJwt

compute encodePublicKey <key> <options>

Command to encode a public key in a specific format.

Parameters:

  • key: Key to encode. It can be a private or public key. The input format can be "hex" or "jwk".
  • options: JSON containing the fields: algorithm "alg" (optional) and "format" to encode, which can be "hex", "jwk", or "pem".

Examples:

compute encodePublicKey 0x0434... {"format":"pem","alg":"ES256"}
compute encodePublicKey {"kty":"EC"...} {"format":"pem"}

compute encodePrivateKey <key> <options>

Command to encode a private key in a specific format.

Parameters:

  • key: Private key to encode. The input format can be "hex" or "jwk".
  • options: JSON containing the fields: algorithm "alg" (optional), "format" to encode (which can be "hex", "jwk", or "pem"), and "type" of pem format if pem is selected.

Examples:

compute encodePrivateKey 0x34... {"format":"pem","alg":"ES256","type":"sec1"}
compute encodePrivateKey {"kty":"EC"...} {"format":"hex"}

compute encodeBase64 <hex>

Command to encode data as base64.

Parameters:

  • hex: Bytes encoded as hex string

compute encodeBase64url <hex>

Command to encode data as base64url.

Parameters:

  • hex: Bytes encoded as hex string

compute decodeBase64 <data> <outputType>

Command to decode data encoded in base64. It's also possible to load it from the saved variables by referencing its name.

Parameters:

  • data: Data to decode.
  • outputType: Output type. It can be "buffer", "json", or "utf8" (default).

Examples:

compute decodeBase64 eyJ0e...
compute decodeBase64 myData

compute decodeBase64url <data>

Command to decode data encoded in base64url. It's also possible to load it from the saved variables by referencing its name.

Parameters:

  • data: Data to decode.

Examples:

compute decodeBase64url eyJ0e...
compute decodeBase64url myData

compute decodeHex <data>

Command to decode data encoded as hex string. It's also possible to load it from the saved variables by referencing its name.

Parameters:

  • data: Data to decode.

Examples:

compute decodeHex 0x41df...
compute decodeHex 41df...