Synergex.SynergyDE.DataEncoding
Encode and decode base64 and base64url strings
WSupported on Windows
|
USupported on Unix
|
VSupported on OpenVMS
|
NSupported in Synergy .NET
|
namespace Synergex.SynergyDE public class DataEncoding
The DataEncoding class provides methods to encode and decode base64 and base64url strings, converting binary data to and from printable ASCII data.
public static FromBase64(characters), alpha
Converts base64-encoded characters (alpha) to the equivalent binary ASCII data.
or
public static FromBase64(string), string
Converts the specified base64-encoded string to the equivalent non-encoded string data.
public static FromBase64URL(characters), alpha
Converts base64url-encoded characters (alpha) to the equivalent binary ASCII data.
or
public static FromBase64URL(string), string
Converts a base64url-encoded string to the equivalent non-encoded string data.
public static ToBase64(characters), alpha
Converts binary data (alpha) to base64-encoded data.
or
public static ToBase64(characters, offset, length), alpha
Converts a subset of binary data (alpha) to base64-encoded data, beginning at offset (int) and continuing for length (int) number of elements.
or
public static ToBase64(string), string
Converts a binary data string to base64-encoded data.
or
public static ToBase64(string, offset, length), string
Converts a subset of a binary data string to base64-encoded data, beginning at offset (int) and continuing for length (int) number of bytes in the string to convert.
public static ToBase64URL(characters), alpha
Converts binary data (alpha) to base64url-encoded data.
or
public static ToBase64URL(characters, offset, length), alpha
Converts a subset of binary data (alpha) to base64url-encoded data, beginning at offset (int) and continuing for length (int) number of elements.
or
public static ToBase64URL(string), string
Converts a binary data string to base64url-encoded data.
or
public static ToBase64URL(string, offset, length), string
Converts a subset of a binary data string to base64url-encoded data, beginning at offset (int) and continuing for length (int) number of bytes in the string to convert.
Discussion
Base64 encoding converts three bytes of binary data into four bytes of printable ASCII, which includes the letters A through Z (both upper- and lowercase), the numbers 0 through 9, the plus sign, and the forward slash. If the number of bytes is not an even multiple of three, the encoded output is padded with one or two equal signs. You must leave enough space for the result of this encoding. The amount of space required depends on the length of the original data, using this formula: ((length + 2) / 3) * 4. The formula for the length of decoded data is ((encoded_length / 4) * 3) - (# trailing equal signs).
Base64url encoding is similar but replaces the plus sign and the forward slash of base64 encoding with a dash and an underscore, respectively, so it can be used as a parameter to a URL.
Synergy .NET routines encode 8-bit characters, not Unicode. If you need to encode Unicode for the string functions above (FromBase64(string), FromBase64URL(string), ToBase64(string), ToBase64(string, offset, length), ToBase64URL(string), and ToBase64URL(string, offset, length)), use the .NET base classes. |