Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Repository files navigation

BaseNcode

CI

A .NET library to encode data in Base-N. F# and C# friendly.

Disclaimer

This library was created as an F# learning exercise. For a more performance-focused implementation, you may want to consider SimpleBase.

Supported Encodings

Usage

All encodings follow the same API pattern so you can extrapolate the following examples to any of the aforementioned encodings.

Import

// F#
open BaseNcode.FSharp
// C#
using BaseNcode;

F# Example

open System.Text

// Encode
let bytes = Encoding.UTF8.GetBytes("foobar")
let encodedString = Base32.encode true bytes
printfn encodedString // MZXW6YTBOI======

// Decode
let decodeErrorToString = function
  | InvalidChar ic -> sprintf "Invalid character %c at index %i" ic.Char ic.Index

match Base32.decode encodedString with
| Ok decodedBytes -> Encoding.UTF8.GetString(decodedBytes) |> printfn // foobar
| Error errors -> Seq.map decodeErrorToString errors |> printfn

C# Example

using System.Text;

// Encode
var bytes = Encoding.UTF8.GetBytes("foobar");
var encodedString = Base32.Encode(bytes);
Console.WriteLine(encodedString); // MZXW6YTBOI======

// Decode
var decodedBytes = Base32.Decode(encodedString);
Console.WriteLine(Encoding.UTF8.GetString(decodedBytes)); // foobar

About

A .NET library to encode data in Base-N (e.g. base32, base64). F# and C# friendly.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.