Giter VIP home page Giter VIP logo

base32-js's People

Contributors

agnoster avatar michaeljcole avatar mikepb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

base32-js's Issues

Error is README.md

Hex: 17O57684bea1f9331418b633a8f373119d765fd4

It cannot be an "O" letter, it's a zero instead ;-)

Hex: 17057684bea1f9331418b633a8f373119d765fd4

Enabling TS import

It will be great to add declaration file as @types/base32-js is not available.

Base32 characters

Is there a strong reason not to use probably most authentic RFC 4648 ( http://tools.ietf.org/html/rfc4648 ) base32 characters? (i.e. alphabet = "abcdefghijklmnopqrstuvwxyz234567")? It took me 2 hours debbuging when I was implementing some protocol requiring "base32" using this library...

base32 non latin characters

If I base32 encode this string my name is hereslkdjfaklsjdfa234234@#$!!@35465*()&(*^*&^*&%&^%///劳动力. I get dnwj0vk1dnjj0ubk41m6awk5edp6pt3actgppv3kd9j6cr9j6cu34ctm80hj889180tkad1p6mn2ga9650n5wah6brn2c996brjjybtfpundefinedmundefinedp. Notice undefined in string output.

Python outputs, NV4SA3TBNVSSA2LTEBUGK4TFONWGWZDKMZQWW3DTNJSGMYJSGM2DEMZUIARSIIJBIAZTKNBWGUVCQKJGFAVF4KRGLYVCMJJGLYSS6LZP4WFLHZMKVDSYVGY=

I would expect this to match the python output or throw an error.

Decoder.finish() incorrect?

I believe your decoder's finish() function is wrong, but I don't know enough of the specifics of the function to pin down exactly why. Either way, you're referencing a variable (bits) that only exists in an Encoder, so there is at least one issue there. Just figured I'd mention it.

Separate sha1 function/make it optional

We use base32 in the browser with browserify. sha1 requires crypto which adds 5k+ lines to the bundle. Also, I don't think sha1 will work in the browser anyway...

In the fork I separated sha1 (milojs@9c7fe12), but I don't think it is a good solution, it will break code that uses it. Any better ideas?

Base32.decode() doesn't work on international alphabet

This works fine for some strings, but for examples like these I get invalid results:

base32.encode("юзер@екзампл.ком.example.com");

output:

9rvundefinedag206mxundefinedecundefinedw7wxjweundefinedy7gq6ay31dnr6rt9ecdqp

input:

base32.decode(9rvundefinedag206mxundefinedecundefinedw7wxjweundefinedy7gq6ay31dnr6rt9ecdqpu");

results in:

N7ªµÏ\Õ@@5;ªµÏ\×3Uk¹¼?;.;Uk¹¾<.example.com

As you can see, it does not result in the original string when it is decoded. Not sure why.

Bower package?

Hey, any chance for a Bower package? It would be cool to use the same code in the browser and on nodejs.

Thanks!

Mike

is there a c lib compatible with this base32-js

Dear Author,

Thanks for your great work! But I need to use it for decoding and use C for encoding... Do you know if there is a C lib which is compatible with this base32 encoder/decoder?

[EXPIRED] Predictable endings with 0 and g

Dear Isaac,
current implementation supports Uint8Array for input like this base32.encode(array), right?
Now I'm curious why both 32-byte (output: 52 chars) and 64-byte (output: 103 chars) arrays as well as relatively long routine UTF8 strings encoded with Base32 predictably ends with either 0 or g.
Any thoughts?

[EXPIRED] Cross-cultural compatibility from the box

Dear Isaac,
console.log(base32.decode(base32.encode("love"))); works as expected, it returns love, hooray.

But let's step aside the anglosaxonian world and type something in Cyrillic. For example, equivalent of word love is любовь in Russian, yet console.log(base32.decode(base32.encode("любовь"))); returns garbled piece of text ?OªµÏ \Õ?Uk��¹²L.

There are various intermediate solutions to this issue. I like the following two:

  • console.log(decodeURIComponent(escape(base32.decode(base32.encode(unescape(encodeURIComponent("любовь"))))))); returns любовь
  • console.log(UTF8.decode(base32.decode(base32.encode(UTF8.encode("любовь"))))); returns любовь
var UTF8 = {
    encode: function(string) {
        string = string.replace(/\r\n/g, "\n");
        var utftext = "";
        for (var n = 0; n < string.length; n++) {
            var c = string.charCodeAt(n);
            if (c < 128) {
                utftext += String.fromCharCode(c);
            } else if ((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            } else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }
        }
        return utftext;
    },
    decode: function(utftext) {
        var string = "",
            i = 0,
            c = 0,
            c2 = 0;
        while (i < utftext.length) {
            c = utftext.charCodeAt(i);
            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            } else if ((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i + 1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            } else {
                c2 = utftext.charCodeAt(i + 1);
                c3 = utftext.charCodeAt(i + 2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }
        }
        return string;
    }
};

Also, there's Encoding API.

const txtencoder = new TextEncoder;
message = "любовь";
txtencoder.encode(message); // returns UTF8 Uint8Array

Could you be so kind and make it working from the box without those additional helpers so users around the globe could enjoy your library without a hassle? Developer of Base91's implementation already did it.

``alias`` make decoding buggy

Hi folks,

I noticed the following behaviour

> base32.decode(base32.encode("deadbeef111"))
< "d{adbe{f111"

which appers to be introduced by the alias behaviour. I nulled the aliases dictionnary to retablish the desired behaviour.

> base32.decode(base32.encode("deadbeef111"))
< "deadbeef111"

difference between this implementation and the Number.prototype.toString

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

NOT CROCKFORD COMPATIBLE

Please : why did you use the U instead of S ?

The crockford alpahbeth is : 0123456789abcdefghjkmnpqrstvwxyz
The one you use is : 0123456789abcdefghjkmnpqrtuvwxyz
Not the S is not present in your alphabet and the U is present.

This is not the Crockford Base32 correct implementation :
source : https://en.wikipedia.org/wiki/Base32 and https://www.crockford.com/base32.html and all other package in all other language (ie Python for my backend....)
I've lost 4 hours to figure out what's happened ....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.