Note that there are some explanatory texts on larger screens.

plurals
  1. POConvert byte array into any base
    primarykey
    data
    text
    <p>I have an array of bytes (any length), and I want to encode this array into string using my own base encoder. In <code>.NET</code> is standard <code>Base64</code> encoder, but what if I want to encode the array in <code>Base62</code>, <code>Base53</code> or <code>Base13</code>?</p> <p>Is it even possible to create such universal base encoder?</p> <p>I know I could do it the simple way, that is, for each byte reserve fixed number of chars (in case of <code>Base62</code>, that would be 5 chars), and do direct byte->chars encoding, but I would be wasting space, as 5 <code>Base62</code> chars are able to contain more than 1 byte, but less than 2 bytes.</p> <p>How should I write such an encoder? Or is there already some class for this?<br> And please note that I need universal decoder as well, otherwise this is useless to me.</p> <h2>Resources</h2> <p>As the solution is already known (use <code>BigInteger</code>), I would just like to put here some resources relating the <code>BigInteger</code> class, as it is not available in .NET 3.5:</p> <p><a href="https://stackoverflow.com/questions/176775/big-integers-in-c">Big integers in C#</a><br> <a href="http://intx.codeplex.com/" rel="nofollow noreferrer">http://intx.codeplex.com/</a><br> <a href="https://svn.apache.org/repos/asf/incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Math/BigInteger.cs" rel="nofollow noreferrer">https://svn.apache.org/repos/asf/incubator/heraldry/libraries/csharp/openid/trunk/Mono/Mono.Math/BigInteger.cs</a><br> <a href="http://www.codeproject.com/KB/cs/BigInteger_Library.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/BigInteger_Library.aspx</a><br> <a href="http://www.codeproject.com/KB/cs/biginteger.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/biginteger.aspx</a> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload