Java: Different results when decoding base64 string with java.util.Base64 vs android.util.Base64

前端 未结 2 575
花落未央
花落未央 2020-12-05 17:50

I\'m working on a client/server system and I\'m trying to do some basic encryption. When I connect to the server, I send a public key as an escaped string across the socket.

相关标签:
2条回答
  • 2020-12-05 18:16

    On android, Use Base64.NO_WRAP instead of Base64.DEFAULT

    @Override
    protected String encode(byte[] bytes) {
        return Base64.encodeToString(bytes, Base64.NO_WRAP);
    }
    
    0 讨论(0)
  • 2020-12-05 18:20

    Instead of Base64.getDecoder() use Base64.getMimeDecoder().

    0 讨论(0)
提交回复
热议问题