我的Android应用程序中的base base-64错误

时间:2017-06-05 07:32:01

标签: android base64

当我尝试解码此字符串时,我想从服务器解码图像:

x1a
                                                                     x00x00x00IHDRx00x00x06@x00x00x03,x08x02x00x00x00x83`xf9vx00x00x00x03sBITx08x08x08xdbxe1Oxe0x00x00x00x96zTXtRaw profile type APP1x00x00xx9cUx8eAx0exc3 x0cx04xefxbcx82'x8cm0xf0x1cTx91*Rxd5Vxf9xffxa1x07Hxdbxecexa5Ykxd7xe1>x9exe3xd8oxf1}xbcxb6xfd1Bx8c1Fx91x1aRKM;Px99R0APxa0,xe4xd3xbdxd5Bx02dxf1xc1Ex19on.xc5|^x18@x9b=x89x85LMxa4xcf|u}=wxfe7xf2xf9xd7)]x99xfe:xb3Zxb3xbaxd8uKl>x01@xf8x00xe7U5txef,xfdxd5x00x00 x00IDATxx9cxecxddxe9{x1cxc7x91xefxfbx88xc8xacxeax05x80x92xa8xcdx1exdb3xf6xxe6xc5xb9xffxffxdb{x9e3xf7xccxe6xd9mKxb6lilkx19/xa2Hx8a$x80xeexaexccxb8/2xb3xbaxd0x00ayx91Xx92xbex9fxe7xb1x0cxf6ZUhx00xd5xbfx8ex88Twx17x00x00x00x00x00x00`xaexecEox00x00x00x00x00x00x00px17x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xacx11`x01x00x00x00x00x00`xd6x08xb0x00x00x00x00x00x000kx04Xx00x00x00x00x00x00x985x02,x00x00x00x00x00x00xccx1ax01x16x00x00x00x00x00x00fx8dx00x0bx00x00x00x00x00x00xb3Fx80x05x00x00x00x00x00x80Y#xc0x02x00x00x00x00x00xc0xa

它给了我这个错误bad base-64

我的编码代码是:

public Bitmap StringToBitMap(String encodedString){
    try {
        byte [] encodeByte=Base64.decode(encodedString, Base64.DEFAULT  );
        Bitmap bitmap=BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
        return bitmap;
    } catch(Exception e) {
      e.getMessage();
        return null;
    }
}

1 个答案:

答案 0 :(得分:-1)

x1a不是base64编码的字符串。 Base64编码的字符串以=或==结尾。 Base64.decode()只能解码用Base64编码的字符串。我希望这是有道理的。