Giter Site home page Giter Site logo

ascii85's People

Contributors

fzakaria avatar larsjaas avatar odisseus avatar ram042 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ascii85's Issues

This class do not support empty arrays

I doesn't support empty byte array

 @Test
public void testEmpty() {
    byte[] empty = new byte[0];
    String encoded = Ascii85.encode(empty);
    try 
    {
        byte[] actual = Ascii85.decode(encoded);
        assertThat(actual, is(empty));
    } 
    catch (Exception e) 
    {
        e.printStackTrace();
    }
}

Encoded string is smaller than expected and therefore allocated ByteBuffer capacity is smaller than original byte array size, causing BufferOverflowException

Encoded a JPEG frame represented by byte array with original length 25820 into a Ascii85 string with 32259 length. Which supposed to be actually 32275 = 25820 * 5 / 4;
Then try to decode that string using Ascii85.decode(); so the Allocated ByteBuffer is 25807 = 32259 * 4 / 5, which is less than original byte array length of 25820;

java.nio.BufferOverflowException
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:164)
at java.nio.ByteBuffer.put(ByteBuffer.java:642)
Ascii85.decode(Ascii85.java:143)

So somehow encoded string turns out to be shorter than byteArrLen * 5/4, which breaks assumption in decode and it causes the exception.

Thanks

Handling of non-ASCII characters

What is the intended behaviour of the decode function (ASCII to binary), when the input string contains characters that are neither ASCII nor whitespace? Should it fail or maybe the invalid characters should just be ignored?

does not properly encode/decode random bytes

SecureRandom random = new SecureRandom();
byte[] randoms = new byte[128];
random.nextBytes(randoms);
String encoded = Ascii85.encode(randoms);
try {
	System.out.println(toHexString(MessageDigest.getInstance("MD5").digest(randoms)));
	System.out.println(toHexString(MessageDigest.getInstance("MD5").digest(Ascii85.decode(encoded))));
} catch (Exception e) {
	e.printStackTrace();
}

This short program outputs two different hashes. Does this library not work for random bytes?

Kotlin

Hi Farid,

I ported your excellent ascii85 to kotlin here

I see you are way into several language... it's time for Kotlin! ๐Ÿ˜›

If you want I can push it and also implement gradle ๐Ÿ˜‰

Maven Central Deploy

Hi,

First of all, thanks for the lib. It seems that the lib is not on maven central as advertised. Is that something that is planned to be fixed?

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.