Namespace: Babel.Licensing
Assembly: Babel.Licensing.dll
Converts between binary data and an Ascii85-encoded string.
Copy public sealed class Ascii85Encoding : IEncoding
Inheritance
object ← Ascii85Encoding
Implements
IEncoding
Inherited Members
object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
See Ascii85 at Wikipedia .
Constructors
Ascii85Encoding()
Copy public Ascii85Encoding ()
Methods
CanDecode(string)
Determine if we can decode the given string.
Copy public static bool CanDecode ( string encoded)
Parameters
Returns
Name Description true if we can decode, false if not.
Exceptions
Name Description Thrown when one or more required arguments are null.
Decode(string)
Decodes the specified Ascii85 string into the corresponding byte array.
Copy public byte [] Decode ( string encoded)
Parameters
Returns
Examples
C# VB
Copy // Encode and decoding using Ascii85Encoding
Ascii85Encoding ascii85 = new Ascii85Encoding ();
byte [] data = Enumerable . Range ( 1 , 10 ). Select (i => ( byte )i). ToArray ();
// Encode data byte[]
// 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA
string encoded = ascii85 . Encode (data);
// encoded string
// !<N?+\"U52;#mp
// Decode encodes string
byte [] decoded = ascii85 . Decode (encoded);
// decoded byte[]
// 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA
Copy ' Encode And decoding using Ascii85Encoding
Dim ascii85 As New Ascii85Encoding()
Dim data As Byte() = Enumerable.Range(1, 10).[Select](Function(i) CByte(i)).ToArray()
' Encode data byte[]
' 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA
Dim encoded As String = ascii85.Encode(data)
' encoded string
' !<N?+\"U52;#mp
' Decode encodes string
Dim decoded() As Byte = ascii85.Decode(encoded)
' decoded byte[]
' 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA
Encode(byte[])
Encodes the specified byte array in Ascii85.
Copy public string Encode ( byte [] bytes)
Parameters
Returns
Name Description An Ascii85-encoded string representing the input byte array.
Examples
C# VB
Copy // Encode and decoding using Ascii85Encoding
Ascii85Encoding ascii85 = new Ascii85Encoding ();
byte [] data = Enumerable . Range ( 1 , 10 ). Select (i => ( byte )i). ToArray ();
// Encode data byte[]
// 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA
string encoded = ascii85 . Encode (data);
// encoded string
// !<N?+\"U52;#mp
// Decode encodes string
byte [] decoded = ascii85 . Decode (encoded);
// decoded byte[]
// 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA
Copy ' Encode And decoding using Ascii85Encoding
Dim ascii85 As New Ascii85Encoding()
Dim data As Byte() = Enumerable.Range(1, 10).[Select](Function(i) CByte(i)).ToArray()
' Encode data byte[]
' 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA
Dim encoded As String = ascii85.Encode(data)
' encoded string
' !<N?+\"U52;#mp
' Decode encodes string
Dim decoded() As Byte = ascii85.Decode(encoded)
' decoded byte[]
' 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA
IsValidChar(char)
Query if the given character is a valid for encoding.
Copy public bool IsValidChar ( char value)
Parameters
Returns
Name Description true if valid character, false if not.
Examples
C# VB
Copy // Check if a character is valid Ascii85 symbol
Ascii85Encoding ascii85 = new Ascii85Encoding ();
bool validAscii85Char1 = ascii85 . IsValidChar ( Convert . ToChar ( 0xEF00 ));
// validAscii85Char1
// flase
bool validAscii85Char2 = ascii85 . IsValidChar ( '!' );
// validAscii85Char2
// true
Copy ' Check if a character is valid Ascii85 symbol
Dim ascii85 As New Ascii85Encoding()
Dim validAscii85Char1 As Boolean = ascii85.IsValidChar(Convert.ToChar(&Hef00))
' validAscii85Char1
' flase
Dim validAscii85Char2 As Boolean = ascii85.IsValidChar("!"C)
' validAscii85Char2
' true
Last updated 3 months ago