Table of Contents

Base64Variant Enum

Definition

Namespace
Bodu.Text.Encoding
Assembly
Bodu.Text.Encoding.dll
Package
Bodu.Text.Encoding 1.0.0
Source
Base64Variant.cs

Identifies the Base64 alphabet and formatting rules used by Base64.

public enum Base64Variant : byte
Extension Methods

Fields

Standard = 0

RFC 4648 §4 standard Base64 using the alphabet A-Z a-z 0-9 + /. Encoded output is padded with = to a multiple of four characters by default.

UrlSafe = 1

RFC 4648 §5 URL- and filename-safe Base64 using the alphabet A-Z a-z 0-9 - _. Padding is omitted by default, matching the conventions used in JWT, OAuth tokens, and most URL contexts.

Mime = 2

RFC 2045 MIME Base64 using the standard alphabet with mandatory line breaks every 76 characters.

Remarks

All variants share the same byte-to-symbol mapping at the bit level; they differ only in alphabet substitutions and the default behaviour around padding and line breaks.

byte[] payload = { 0xFB, 0xEF, 0xFF };

var standard = Base64.Encode(payload);                          // may contain '+' and '/'
var urlSafe = Base64.Encode(payload, Base64Variant.UrlSafe);    // '-' and '_' instead
var mime = Base64.Encode(payload, Base64Variant.Mime);          // MIME transfer profile

Applies to

ProductVersions
.NET8, 10