Decrypting “SunJCE” AES encrypted data on Android

前端 未结 3 1610
离开以前
离开以前 2021-02-11 04:34

We need to write some Android code to decrypt some data sent from our server. Our server team gave us some sample decryption code which uses the \"SunJCE\" provider, which unfo

3条回答
  •  借酒劲吻你
    2021-02-11 05:22

    The same garbage is also present in the Java code. It's just that you probably run this on Windows that uses the default Latin (ISO_8859_1) character set and that Android uses UTF-8 by default. It also depends on the console and font used to print out the characters. In this case it is likely that the padding that is used doesn't print on the Windows console but does on the Android code.

    You need to see the byte array (e.g. in hexadecimals) to find out which padding is used and then strip it off before turning the plaintext into a string.

提交回复
热议问题