package core:encoding/base64
Overview
Base64 encoding and decoding.
A secondary param can be used to supply a custom alphabet to encode and a matching decoding table to decode.
If none is supplied it just uses the standard Base64 alphabet.
By default encode emits padding. Encode options can omit it: with
{.No_Padding} the output is the canonical unpadded ("raw") form of
RFC 4648 section 3.2, and encoded_len reports the shorter length.
By default decode is lenient, accepting padded and unpadded input and not
checking the trailing padding bits. Decode options can enable strict
(RFC 4648 section 3.5) canonical decoding: {.Strict} requires correct
padding and zero trailing bits, while {.Strict, .No_Padding} accepts only
canonical unpadded input.
Index
Constants (1)
Variables (4)
Procedures (8)
Procedure Groups (0)
This section is empty.
Types
Decode_Error ¶
Decode_Error :: enum int { None, Invalid_Character, Invalid_Padding, Non_Canonical, }
Decode_Option ¶
Decode_Option :: enum int { // Strict requires canonical input as described in RFC 4648 section 3.5: // trailing padding bits must be zero, padding must be exact, and padding // characters may only appear at the end. Strict, // No_Padding rejects the padding character, requiring unpadded input. No_Padding, }
Decode_Option selects optional validation performed by the decode routines.
Decode_Options ¶
Decode_Options :: bit_set[Decode_Option; u8]
Decode_Options is a set of Decode_Option values.
Related Procedures With Parameters
Encode_Option ¶
Encode_Option :: enum int { // No_Padding omits the padding character from the output (RFC 4648 // section 3.2), producing the canonical unpadded ("raw") form. // Combine with ENC_URL_TABLE for unpadded base64url, as used by JOSE. No_Padding, }
Encode_Option selects optional behavior of the encode routines.
Encode_Options ¶
Encode_Options :: bit_set[Encode_Option; u8]
Encode_Options is a set of Encode_Option values.
Related Procedures With Parameters
Error ¶
Error :: union { runtime.Allocator_Error, io.Error, Decode_Error, }
Related Procedures With Returns
Constants
PADDING ¶
PADDING :: '='
Variables
DEC_TABLE ¶
@(rodata) DEC_TABLE: [256]i8 = …
ENC_TABLE ¶
@(rodata) ENC_TABLE: [64]u8 = …
Procedures
decode ¶
decode :: proc( data: string, DEC_TBL: [256]i8 = DEC_TABLE, dst: []u8 = nil, allocator := context.allocator, options: bit_set[Decode_Option; u8] = Decode_Options{}, ) -> (decoded: []u8, err: Error) {…}
encode ¶
encode :: proc( data: []u8, ENC_TBL: [64]u8 = ENC_TABLE, allocator := context.allocator, options: bit_set[Encode_Option; u8] = Encode_Options{}, ) -> (encoded: string, err: runtime.Allocator_Error) #optional_ok {…}
encoded_len ¶
encoded_len :: proc(data: []u8, options: bit_set[Encode_Option; u8] = Encode_Options{}) -> int {…}
Procedure Groups
This section is empty.
Source Files
Generation Information
Generated with odin version dev-2026-10 (vendor "odin") Windows_amd64 @ 2026-10-12 23:46:18.383355400 +0000 UTC