std/string/base64

Standard Library documentation

Base64 encoders and decoders.

Module

Name
std/string/base64
Area
Standard Library
Source
modules/std/string/base64.zzm

NAME

std/string/base64 - Base64 encoders and decoders.

SYNOPSIS

  from std/string/base64 import *;

  let raw := to_binary( "Hello, world!" );

  let b64 := encode(raw);
  let text := decode(b64);

  let safe := encode_urlsafe(raw);
  let original := decode_urlsafe(safe);

IMPLEMENTATION SUPPORT

This module is supported by all implementations of ZuzuScript.

DESCRIPTION

This module provides Base64 encoding and decoding helpers.

The URL-safe variant uses - and _ instead of + and /. It also omits trailing = padding so encoded text can be placed into URLs more easily.

EXPORTS

Functions

  • encode(BinaryString value)

    Parameters: value is binary input data. Returns: String. Encodes value as standard Base64 text.

  • decode(String value)

    Parameters: value is standard Base64 text. Returns: BinaryString. Decodes Base64 text into bytes.

  • encode_urlsafe(BinaryString value)

    Parameters: value is binary input data. Returns: String. Encodes value as URL-safe Base64 text without trailing padding.

  • decode_urlsafe(String value)

    Parameters: value is URL-safe Base64 text. Returns: BinaryString. Decodes URL-safe Base64 text, adding missing trailing padding automatically.

COPYRIGHT AND LICENCE

std/string/base64 is copyright Toby Inkster.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.