Skip to content

Roydl/Text

Repository files navigation

.NET Core Cross-platform License

Build+Test Commits Source

NuGet NuGet Website Mirror

Roydl.Text

The idea was to create a comfortable way of binary-to-text encoding.

You can easily create instances of any type to translate Stream, byte[] or string data. Extension methods are also provided for all types.

Install:

$ dotnet add package Roydl.Text

Binary-To-Text Encoding

Type Encoding
Base-2 Binary character set: 0 and 1
Base-8 Octal character set: 0-7
Base-10 Decimal character set: 0-9
Base-16 Hexadecimal character set: 0-9 and a-f
Base-32 Standard 32-character set: A–Z and 2–7; = for padding
Base-64 Standard 64-character set: A–Z, a–z, 0–9, + and /; = for padding
Base-85 Standard 85-character set: !"#$%&'()*+,-./, 0-9, :;<=>?@, A-Z, []^_` and a-u
Base-91 Standard 91-character set: A–Z, a–z, 0–9, and !#$%&()*+,-.:;<=>?@[]^_`{|}~"

Usage:

// The `value` must be type `string` or `byte[]`, if `BinToTextEncoding` is
// not set, `Base64` is used by default.
string base85text = value.Encode(BinToTextEncoding.Base85);
byte[] original = value.Decode(BinToTextEncoding.Base85); // if `value` to decode is `byte[]`
string original = value.DecodeString(BinToTextEncoding.Base85); // if `value` to decode is `string`

// The `value` of type `string` can also be a file path, which is not
// recommended for large files, in this case you should create a
// `Base85` instance and use `FileStream` to read and write.
string base85text = value.EncodeFile(BinToTextEncoding.Base85);
byte[] original = value.DecodeFile(BinToTextEncoding.Base85);

Would you like to help?

  • Star this Project ⭐ and show me that this project interests you 🤗
  • Open an Issue ☕ to give me your feedback and tell me your ideas and wishes for the future 😎
  • Open a Ticket 📫 if you don't have a GitHub account, you can contact me directly on my website 😉
  • Donate by PayPal 💸 to buy me some cakes 🍰

Please note that I cannot fix bugs that are unknown to me. So do yourself and me the favor and get in touch with me. 🤕