public static short[] readBytesFromImage(BufferedImage bimg, String key) {
        //System.out.println("[Key] " + key);

        int w = bimg.getWidth();
        int h = bimg.getHeight();

        RC4 prng = new RC4(EncryptionProvider.sha256(key.getBytes()));
        Set<Integer> usedPixels = new HashSet<>();

        // Invalid header
        if (!validateHeaderByte(bimg, prng, usedPixels, key)) {
            return null;
        }
        
        int length = readMessageLength(prng, usedPixels, bimg, key);

        //System.out.println("[Length] " + length);
        if (length <= 0) {
            return null;
        }

        // Get first 4 bytes to decode message length
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        BitOutputStream bos = new BitOutputStream(baos);

        // Read data bits, skip first validation byte, skip first 4 bytes (message length)
        for (int i = 8 * (4 + 1) - 1; i < 8 * length + 32 + 7; i++) {
            int index = nextPixelIndex(prng, usedPixels, h, w);

            ////System.out.print(index + ", ");

            int x = getPixelX(index, h, w);
            int y = getPixelY(index, h, w);
            int byteNumber = getPixelZ(index, h, w);

            int pixel = bimg.getRGB(x, y);

            int lsb = (pixel >> (8 * byteNumber)) & 0x01;

            //System.out.println("lsb: " + lsb);
            
            bos.writeBits(1, lsb);
        }

        bos.flush();

        
        byte[] data = baos.toByteArray();
        short[] d = new short[data.length];
        for (int i = 0; i < data.length; i++) {
            d[i] = (short) (data[i] & 0xFF);
        }
        
        
        //System.out.println("[Data array] " + Arrays.toString(data));

        return d;
    }