TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How does Base32 (or any Base2^n) work exactly?

70 点作者 pchm超过 1 年前

8 条评论

gnabgib超过 1 年前
Hey Piotr&#x2F;pchm, I&#x27;m not sure I follow your argument that Base32 is less popular because it&#x27;s not a standard (there is a standard - RFC4648 as you mention).<p>Not implementing the RFC, is not implementing Base32, changing the order, or using 32 emoji does not make it Base32. Put another way, you can change the order of characters in Base64, or use a different dictionary, and indeed there are several variants of that too (BinHex4, Uuencoding, Base64Url, B64) - there are specific implementation detail concerns there too.<p>Base64 won out as a reasonably dense way to encode binary data in 7-bit safe ASCII for use in email, and later http headers (where spacing and line length may be modified in transit, and some ASCII characters are prohibited - eg 0x00&#x2F;null). Part of the reason is; bit-grouping makes encode&#x2F;decode simpler (you can use bit shifting). Something like ASCII85&#x2F;Base85 which is a more dense encoding, and close to the maximum you can get in 7 bit safe ASCII (94 characters 33-126 if space is important, 95 if space quantity can be preserved) but you have to use multiply&#x2F;divide instructions. The union of bit-shift speed (power of 2) and 7-bit safe ASCII characters (max 94 values) is: binary, base4, octal, hexadecimal, base32, and base64.<p>For human readability, especially verbal communication, hexadecimal or base32 are advantageous in that they are more dense than decimal, can be generated via bit-shifting vs more complex processor instructions, but you needn&#x27;t also communicate the character&#x27;s case (unlike Base64).
评论 #38675902 未加载
rsk超过 1 年前
If anyone interested, here is my article about optimization of encoding&#x2F;decoding u128 to base62 (non power of 2) <a href="https:&#x2F;&#x2F;dev.to&#x2F;rsk&#x2F;optimization-of-u128-to-base62-encoding-31fe" rel="nofollow noreferrer">https:&#x2F;&#x2F;dev.to&#x2F;rsk&#x2F;optimization-of-u128-to-base62-encoding-3...</a>
Uptrenda超过 1 年前
A few other bases that are interesting:<p>Base36: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ<p>Good encoding for binary data in textual contexts. Such as where you have parameter inputs or database fields that are constrained and only accept certain characters. The lack of spaces means that it can be used on the command-line easily. Example use: IRC channel names.<p>Base64: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz<p>Same as above but it adds lower-case alphabet characters. This is important because as you restrict the number of characters allowed in a byte: the length of the string goes up massively. With more characters the coding is more efficient. Example use: YouTube video ids.<p>Base92: &quot;0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@#$%^&amp;*()_+{}\&quot;&lt;&gt;?`-=[];&#x27;,.&#x2F;|&quot;<p>Base92 is every character you can make on a standard key-board (I&#x27;ve replaced space with pipe here.) It includes many characters that have special meanings on the command-line or may be used as delimiters in text-based protocols. So while this offers a more &#x27;efficient&#x27; encoding scheme for binary data it may break in some contexts. It&#x27;s best where the input allows for typical formatting. Example use: forum &#x2F; chat messages.<p>BaseN encoding schemes are interesting because they allow you to use standard text-fields in many systems to store binary data. The most well-known here is base64 which allows browsers to embed whole files as text and store them directly in the HTML. Some sites use these for optimization hacks.
评论 #38675180 未加载
评论 #38675153 未加载
评论 #38675211 未加载
sedatk超过 1 年前
Base32 encouraged me to develop my own Base32-encoder on .NET. I eventually added other encoding types over the years, leading to the library called SimpleBase. It&#x27;s now being used by popular packages like Ipfs.Core, net-dns, and KubeOps.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;ssg&#x2F;SimpleBase">https:&#x2F;&#x2F;github.com&#x2F;ssg&#x2F;SimpleBase</a>
daisydaisytts超过 1 年前
Just putting this here for alternate baseX: <a href="https:&#x2F;&#x2F;github.com&#x2F;qntm&#x2F;base2048">https:&#x2F;&#x2F;github.com&#x2F;qntm&#x2F;base2048</a>
westurner超过 1 年前
Radix: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Radix" rel="nofollow noreferrer">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Radix</a><p>- &quot;Golden ratio base is a non-integer positional numeral system&quot; (2023) <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37969716">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37969716</a><p>Number systems &gt; Classification: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Number#Classification" rel="nofollow noreferrer">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Number#Classification</a> ; N natural numbers, Z[±] integers, Q rational&#x2F;s, R Reals, C complex numbers (with complex conjugate exponents), Infinity or Infinities, ; C ⊆ R ⊆ Q ⊆ Z ⊆ N<p>***<p><pre><code> i^4x ~= e^iπx </code></pre> Also, perhaps this is a better representation for a continuum of reals:<p><pre><code> e^(x*yi*zπ) </code></pre> But then there&#x27;s no zero; only quantities approaching zero.<p><pre><code> e^(x*yi*zπ) * e^(a*bi*cπ) </code></pre> But then there are still no negative numbers, so:<p><pre><code> sign * e^(x*yi*zπ) * e^(a*bi*cπ) </code></pre> Where `sign` is in {-1,0,1}, or maybe just this would be the ultimate radix:<p><pre><code> sign * e^(x*yi*zπ) </code></pre> But then represent infinity, or infinity_expr1 (because e.g. 1&#x2F;x != 2&#x2F;x except at x=0)
waynesonfire超过 1 年前
Which encoding eliminates symbols that can be confused ljke O vs 0? Or I vs l
评论 #38676991 未加载
评论 #38677321 未加载
malodyets超过 1 年前
I’m a big fan of base58<p>+ almost as efficient as base64 + no special characters + no padding characters
评论 #38677298 未加载
评论 #38675864 未加载
评论 #38675723 未加载