a9script

Docs / Language & functions

a9script authoring pack — encoding functions

The encoding functions, with their arguments and a line of real script each. Called by bare name; nothing is imported. A call marked pauses does real work outside the script: the run is saved, and continues on the next line with the result.

base64Encode(text) — pauses

Text to base64, read as UTF-8 — so accented letters and emoji encode as themselves.

  • text (string) — The text to encode.

Answers: The base64 text.

const encoded = base64Encode(input.event.body.customer);
log(encoded);

base64Decode(text) — pauses

Base64 back to text. Anything that is not base64, and anything whose bytes are not text, is refused — a half-decoded string full of replacement characters is corruption that looks like data.

  • text (string) — The base64 to decode.

Answers: The decoded text.

const decoded = base64Decode("aGVsbG8=");
log(decoded); // hello

hexEncode(text) — pauses

Text to lower-case hexadecimal, read as UTF-8 — two characters per byte.

  • text (string) — The text to encode.

Answers: The hexadecimal text.

log(hexEncode("hi")); // 6869

hexDecode(text) — pauses

Hexadecimal back to text. An odd number of characters, anything outside 0-9a-f, and bytes that are not text are all refused.

  • text (string) — The hexadecimal to decode.

Answers: The decoded text.

log(hexDecode("6869")); // hi
Rendered from docs/guide/authoring-pack-functions-encoding.md in the product's own repository, at build time. Found a problem on this page? Write to the address in the footer.