aiq / basexx

A Lua library which provides base2(bitfield), base16(hex), base32(crockford/rfc), base64(rfc/url), base85(z85) decoding and encoding.
MIT License
84 stars 28 forks source link

Crockford example is incorrect #3

Closed jpetso closed 8 years ago

jpetso commented 8 years ago

First up, this library looks awesome and good job for including test cases / example conversions for all the codecs. Now for the issue!

The README gives this example:

basexx.from_crockford( "axqqeb10d5u20wk5c5p6ry90exqq4uvk44" ) --> Wow, it really works!

This example decodes a "u" character; however, the spec at http://www.crockford.com/wrmg/base32.html does not say a word about decoding "u" or even the upper-case "U". If I had to guess, I'd think that maybe you got the alphabet from https://github.com/agnoster/base32-js which uses an alphabet derived from Crockford but is not the original one, and that one includes "u" as well.

Since I'm currently working on a (C++) library for base-N codecs, here's what my encoding result looks like:

base32::encode(std::string("Wow, it really works!"));
"AXQQEB10D5T20WK5C5P6RY90EXQQ4TVK44" // my result
"AXQQEB10D5U20WK5C5P6RY90EXQQ4UVK44" // upper-case version of your example
aiq commented 8 years ago

Hey, thanks for the info and the nice words.

The example in the README was outdated. basexx produces also AXQQEB10D5T20WK5C5P6RY90EXQQ4TVK44, since version 0.2.0[1].

I fixed the README and added a new test[2].

[1] https://github.com/aiq/basexx/blob/master/CHANGELOG.adoc [2] https://github.com/aiq/basexx/commit/16328ee08a6c8dbc58da0131df82ca8caba2a8eb

jpetso commented 8 years ago

Awesome, thanks!