Giter Club home page Giter Club logo

basencoding's Issues

Add Validate function?

I'm using this library as part of a project of mine, and I've found in some cases there would be a need to validate an encoded string, that is, make sure that all of the characters are valid and that the formatting is correct.

Would this be possible to add?

BUG found

There is a huuuge bug here:

For example, if you enter "ap\n" ("ap" and NEW LINE) here:

http://kvanttt.github.io/BaseNcoding/

using Base=4096 and MaxBitCount=12 it will encode into:

ูš+

which decodes back into "az" instead of its original value "ap\n" ("ap" and NEW LINE).

This bug is not related to web site character encoding nor new line differences between OSs (\r, \n vs \r\n) but it is easily reproducable with unit tests.

Bug Found in Base32 Encode and Decode.

Hello,
First of all, thanks for this nice Library, It has really been helpful.
I and my colleague @ron4fun found a bug in the encoding and decoding of certain values to Base32.
A test example is the Name "Ronald" without the quotes, verifying with other encoders gives "KJXW4YLMMQ======" but yours gives "KJXW4YLMMQ====" which is wrong.
I have fixed the issue in my Pascal Port but just decided to inform you about the bug.
I could provide a pull request if you want.
Regards.

Binary encoding is worse than with `btoa`.

I have a 169 bytes image. Lets encode it.

Just run it in the browser console (on https://kvanttt.github.io/BaseNcoding/):

let dataUrl = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAA+SURBVEhL7dIxCgAwCMVQ739pu/yh0JYgXfNWlSxWv9UhgwkDyAAygAygXEo/8k032dhkMGEAGUAGkAHQvQC3veR+Ql0lAQAAAABJRU5ErkJggg==`;
let base64 = dataUrl.slice("data:image/png;base64,".length);
let binaryString = atob(base64);

var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var baseN = new BaseN(alphabet, 64);
baseN.encodeString(binaryString);

The result is:

wolQTkcNChoKAAAADUlIRFIAAAAgAAAAIAgCAAAAw7wYw63CowAAAAFzUkdCAMKuw44cw6kAAAAEZ0FNQQAAwrHCjwvDvGEFAAAACXBIWXMAAA7DgwAADsODAcOHb8KoZAAAAD5JREFUSEvDrcOSMQoAMAjDhVDDr39pwrvDvMKhw5DCliBdw7NWwpUsVsK/w5UhwoMJA8OIADLCgAzCoFxKP8OyTTfDmcOYZDBhABlABsKQAcOQwr0AwrfCvcOkfkJdJQEAAAAASUVORMKuQmDCgC

282 chars.

With "Base85" the length is 265.

The expected result:

iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAA+SURBVEhL7dIxCgAwCMVQ739pu/yh0JYgXfNWlSxWv9UhgwkDyAAygAygXEo/8k032dhkMGEAGUAGkAHQvQC3veR+Ql0lAQAAAABJRU5ErkJggg==

228 chars. (Math.ceil(169*4/3+2), btoa(binaryString))

With "Base85" the length should be ~212 (169*5/4).


Does it work as planned?

Nuget Package

Hi, I am interested in your code and I'd like to be able to consume the library as a nuget package. Do you have any official nuget package feed that can provide me with the package?

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.