Path: redb-route/redb.Route/Serialization/Base64MessageSerializer.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Serialization/Base64MessageSerializer.cs
----
using System.Text;
namespace redb.Route.Serialization;
/// Base64 as a data format: Marshal("application/base64") encodes the body, Unmarshal<byte[]>("application/base64") decodes it.
public sealed class Base64MessageSerializer : BinaryWrapperSerializer
{
/// Content type the format is registered under by default.
public const string DefaultContentType = "application/base64";
///
public override string ContentType => DefaultContentType;
///
protected override string FormatName => "Base64";
///
protected override byte[] Encode(byte[] payload) => Encoding.ASCII.GetBytes(Convert.ToBase64String(payload));
///
protected override byte[] Decode(byte[] data) => Base64Text.Decode(Encoding.ASCII.GetString(data).Trim());
}