Base64Helper

Encoding and Decoding

Methods for encoding plain text to Base64 and decoding Base64 strings back to text.

Methods for encoding plain text to Base64 and decoding Base64 strings back to text.

EncodeToBase64 takes a plain string and returns its UTF-8 Base64 encoded representation. DecodeFromBase64 takes a Base64 string and decodes it to UTF-8 text - throws if the input is not valid Base64 or if the decoded bytes are not valid UTF-8. WithInput sets the Base64 string to work with as a fluent entry point - chain SaveTo or other methods after it. The static encode and decode methods can be called directly on GPAL.Base64 for one-step conversions.

Examples

GPAL Fluent: High-level fluent C# API

//EncodeToBase64 and DecodeFromBase64 are synchronous and return the result directly. Use the fluent WithInput pattern when you need to save decoded binary content to a file rather than get a string.

// Encode a string to Base64 string encoded = GPAL.Base64.EncodeToBase64("Hello, World!"); // Result: SGVsbG8sIFdvcmxkIQ== // Decode a Base64 string string decoded = GPAL.Base64.DecodeFromBase64("SGVsbG8sIFdvcmxkIQ=="); // Result: Hello, World! // Fluent pattern: set input and save decoded bytes to file GPAL.Base64 .WithInput(encodedFileData) .SaveTo(GPAL.FileFor("C:\output\document.pdf"));