Gapotchenko.FX.Data.Encoding.Base64
2022.2.7
Prefix Reserved
See the version list below for details.
dotnet add package Gapotchenko.FX.Data.Encoding.Base64 --version 2022.2.7
NuGet\Install-Package Gapotchenko.FX.Data.Encoding.Base64 -Version 2022.2.7
<PackageReference Include="Gapotchenko.FX.Data.Encoding.Base64" Version="2022.2.7" />
paket add Gapotchenko.FX.Data.Encoding.Base64 --version 2022.2.7
#r "nuget: Gapotchenko.FX.Data.Encoding.Base64, 2022.2.7"
// Install Gapotchenko.FX.Data.Encoding.Base64 as a Cake Addin #addin nuget:?package=Gapotchenko.FX.Data.Encoding.Base64&version=2022.2.7 // Install Gapotchenko.FX.Data.Encoding.Base64 as a Cake Tool #tool nuget:?package=Gapotchenko.FX.Data.Encoding.Base64&version=2022.2.7
Overview
The module provides the implementation of binary-to-text encoding algorithms belonging to Base64 family.
Quick Start
Use the following code to get the textual representation of the specified data in Base64 encoding:
using Gapotchenko.FX.Data.Encoding;
var encodedText = Base64.GetString(data);
To get the data back from the textual representation, use the following method:
var decodedData = Base64.GetBytes(encodedText);
Iterative Data Processing
If you need to encode the data iteratively then the following approach becomes handy:
var encoding = Base64.Instance;
// Create a streaming encoder that iteratively encodes the data and
// writes the encoded text to the specified text writer.
var stream = encoding.CreateEncoder(textWriter);
// Stream the data to encode.
stream.Write(...); // block 1
// ...
stream.Write(...); // block N
// Flush the data to the underlying text writer.
stream.Flush();
The same approach is valid for the decoding operation which is the opposite of the encoding:
var encoding = Base64.Instance;
// Create a streaming decoder that iteratively reads the encoded text
// from the specified text reader and decodes the data on the fly.
var stream = encoding.CreateDecoder(textReader);
// Stream the decoded data.
stream.Read(...); // block 1
// ...
stream.Read(...); // block N
Available Base64 Algorithms
Base64 family of binary-to-text data encodings consists of several attested algorithms with predefined parameters:
Algorithm | Aliases | Gapotchenko.FX Implementation | Alphabet | Case-Sensitivity | Data Encoding Efficiency* |
---|---|---|---|---|---|
Base64 | Base64 |
ABCDEFGHIJKLMNOPQRSTUVWXYZ<br/>abcdefghijklmnopqrstuvwxyz0123456789+/ | Yes | 0.75 | |
Base64 URL | base64url | Base64Url |
ABCDEFGHIJKLMNOPQRSTUVWXYZ<br/>abcdefghijklmnopqrstuvwxyz0123456789-_ | Yes | 0.75 |
* Data encoding efficiency is the ratio between the amount of original data and its encoded representation.
Recommended Base64 Algorithm
Among all other posibilities, it is recommended to use the standard Base64 algorithm which is provided by Base64
class.
All other predefined algorithms are provided by the corresponding classes of Gapotchenko.FX.Data.Encoding.Base64
module.
Custom Base64 Algorithms
Once in a while, you may encounter a custom Base64 algorithm that is neither widely known nor characterized. In that case, you can instantiate a custom data encoding algorithm with the desired parameters by hand:
var encoding = new CustomBase64(...);
If you want to formalize a custom algorithm even further, you may opt-in to creating a separate class for it with a convenient accessor property:
/// <summary>
/// Defines a custom Base64 data encoding algorithm.
/// </summary>
sealed class FooBase64 : CustomBase64
{
FooBase64() :
base(...)
{
}
public static FooBase64 Instance { get; } = new FooBase64();
}
That will allow you to use the algorithm effortlessly from several places in the codebase later:
var encodedText = FooBase64.Instance.GetString(...);
Commonly Used Types
- Gapotchenko.FX.Data.Encoding.Base64
- Gapotchenko.FX.Data.Encoding.Base64Url
Other Modules
Let's continue with a look at some other modules provided by Gapotchenko.FX:
- Gapotchenko.FX
- Gapotchenko.FX.AppModel.Information
- Gapotchenko.FX.Collections
- Gapotchenko.FX.Console
- Gapotchenko.FX.Data
- Gapotchenko.FX.Diagnostics
- Gapotchenko.FX.IO
- Gapotchenko.FX.Linq
- Gapotchenko.FX.Math
- Gapotchenko.FX.Memory
- Gapotchenko.FX.Security.Cryptography
- Gapotchenko.FX.Text
- Gapotchenko.FX.Threading
Or look at the full list of modules.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 is compatible. netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 is compatible. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 is compatible. net472 is compatible. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 2.0
- Gapotchenko.FX (>= 2022.2.7)
- Gapotchenko.FX.Data.Encoding (>= 2022.2.7)
-
.NETCoreApp 2.1
- Gapotchenko.FX (>= 2022.2.7)
- Gapotchenko.FX.Data.Encoding (>= 2022.2.7)
-
.NETCoreApp 3.0
- Gapotchenko.FX (>= 2022.2.7)
- Gapotchenko.FX.Data.Encoding (>= 2022.2.7)
-
.NETFramework 4.6
- Gapotchenko.FX (>= 2022.2.7)
- Gapotchenko.FX.Data.Encoding (>= 2022.2.7)
-
.NETFramework 4.7.1
- Gapotchenko.FX (>= 2022.2.7)
- Gapotchenko.FX.Data.Encoding (>= 2022.2.7)
-
.NETFramework 4.7.2
- Gapotchenko.FX (>= 2022.2.7)
- Gapotchenko.FX.Data.Encoding (>= 2022.2.7)
-
.NETStandard 2.0
- Gapotchenko.FX (>= 2022.2.7)
- Gapotchenko.FX.Data.Encoding (>= 2022.2.7)
-
.NETStandard 2.1
- Gapotchenko.FX (>= 2022.2.7)
- Gapotchenko.FX.Data.Encoding (>= 2022.2.7)
-
net5.0
- Gapotchenko.FX (>= 2022.2.7)
- Gapotchenko.FX.Data.Encoding (>= 2022.2.7)
-
net6.0
- Gapotchenko.FX (>= 2022.2.7)
- Gapotchenko.FX.Data.Encoding (>= 2022.2.7)
-
net7.0
- Gapotchenko.FX (>= 2022.2.7)
- Gapotchenko.FX.Data.Encoding (>= 2022.2.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.