Git Product home page Git Product logo

base32's People

Contributors

januswel avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

base32's Issues

Dreading bug with zeros

Inserted this library in a new TypeScript/VueJS project, at first for base32 decoding, I spent 3 hours on understanding why my server rejected the data decoded from base32. Turns out this library is dropping some zeros. ๐Ÿ˜ฒ

The first issue I faced :
MZ2H7MN3ACFGINNTVS73V2Q6QSZGGD2GUMBBD34G67IGG4LL2FRQ====
decodes to :
0x66747fb1bb8a6435b3acbfbaea1e84b2630f46a30211ef86f7d063716bd163
There's a 00 char missing between bb and 8a

Now I investigated further :

import { encode as encode, decode as decode} from '@januswel/base32';

const start0 = '1234567890abcdef';
const encoded0 = encode(start0);
const decoded0 = decode(encoded0);
console.log(start0 == decoded0);
console.log(start0);
console.log(decoded0);

const start = '66747fb1bb008a6435b3acbfbaea1e84b2630f46a30211ef86f7d063716bd163';
const encoded = encode(start);
const decoded = decode(encoded);
console.log(start == decoded);
console.log(start);
console.log(decoded);

const start2 = '66747fb1bb8a6435b3acbfbaea1e84b2630f46a30211ef86f7d063716bd163';
const encoded2 = encode(start2);
const decoded2 = decode(encoded2);
console.log(start2 == decoded2);
console.log(start2);
console.log(decoded2);

Output

true
1234567890abcdef
1234567890abcdef
false
66747fb1bb008a6435b3acbfbaea1e84b2630f46a30211ef86f7d063716bd163
66747fb1bb8a6435b3acbfbaea1e84b2630f46a30211ef86f7d063716bd163
false
66747fb1bb8a6435b3acbfbaea1e84b2630f46a30211ef86f7d063716bd163
66747fb1bb8a6435b3acbfbaea1e84b2630f46a3211ef86f7d063716bd163

First example is OK as in the light test vectors in this repo.
The second example it drops 0x00, and the third one it drops half a byte (a single "hex" 0) and the output is not even "hex bytes consistent".

โ€‹

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.