agnoster / base32-js

Base32 encoding for JavaScript, based (loosely) on Crockford's Base32
https://github.com/agnoster/base32-js
MIT License
121 stars 61 forks source link

difference between this implementation and the Number.prototype.toString #21

Open Strandedpirate opened 6 years ago

Strandedpirate commented 6 years ago

I'm getting different results between implementations. I'm missing something. Other than the fact that this implementation is using crockford's limited character set why are these two base32 encodings wildly off?

var number = 14974;
number.toString(32); // -> eju
base32.encode(number.toString()); // -> 64u3jdtm
Firer commented 6 years ago

Number.prototype.toString is changing a base 10 number into the chosen base/radix. https://en.wikipedia.org/wiki/Radix/

This library is turning an arbitrary string into a base 32 string.

In summary, the number 14974 is different from the string "14974".