Class Base92JsonSafeEncoder
Encodes arbitrary bytes with a canonical base-92 representation that can appear inside a JSON string without JSON string escaping.
Inherited Members
Namespace: Eigenverft.NetLib.Infrastructure.Text
Assembly: Eigenverft.NetLib.Infrastructure.dll
Syntax
public static class Base92JsonSafeEncoder
Remarks
The alphabet contains every printable ASCII character from U+0021 through U+007E except double quote
(") and backslash (</code>). Space is excluded by starting at U+0021. The resulting 92 symbols are:
!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~.
Encoding interprets the non-leading-zero input bytes as one unsigned big-endian base-256 integer and converts
it to base 92. Each leading zero byte is represented by one leading !, the zero-valued alphabet symbol.
Empty input encodes as an empty string and no padding is used.
This type provides representation only. Base92JsonSafe does not provide cryptographic protection and should not
be treated as encryption. JSON-safe here means JSON-string-safe; characters such as <, >,
&, apostrophe, and slash remain part of the alphabet and may require separate handling in other contexts.
Fields
| Edit this page View SourceAlphabet
Gets the canonical 92-character alphabet in digit order from zero through 91.
Declaration
public const string Alphabet = "!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~"
Field Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceDecode(string)
Decodes one canonical Base92JsonSafe string.
Declaration
public static byte[] Decode(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The encoded value. |
Returns
| Type | Description |
|---|---|
| byte[] | The decoded bytes. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| FormatException |
|
Encode(byte[])
Encodes bytes using the canonical Base92JsonSafe representation.
Declaration
public static string Encode(byte[] bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | bytes | The bytes to encode. |
Returns
| Type | Description |
|---|---|
| string | The Base92JsonSafe string. |
TryDecode(string?, out byte[])
Attempts to decode one canonical Base92JsonSafe string.
Declaration
public static bool TryDecode(string? value, out byte[] bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The encoded value. |
| byte[] | bytes | Receives the decoded bytes on success. |
Returns
| Type | Description |
|---|---|
| bool |