Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Base64

Provides a set of functions to operate with Base64 strings.

State Variables

_TABLE

Base64 Encoding/Decoding Table See sections 4 and 5 of https://datatracker.ietf.org/doc/html/rfc4648

string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

_TABLE_URL

string internal constant _TABLE_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";

Functions

encode

Converts a bytes to its Bytes64 string representation.

function encode(bytes memory data) internal pure returns (string memory);

encodeURL

Converts a bytes to its Bytes64Url string representation. Output is not padded with = as specified in https://www.rfc-editor.org/rfc/rfc4648[rfc4648].

function encodeURL(bytes memory data) internal pure returns (string memory);

_encode

Internal table-agnostic conversion

function _encode(bytes memory data, string memory table, bool withPadding) private pure returns (string memory);