RSA Encryption: Difference between Java and Android

前端 未结 3 660
眼角桃花
眼角桃花 2020-12-04 15:57

I am using RSA to encrypt username and password on Android and decrypt them on server (tomcat 6, java 1.6). Android Encryption:

    PublicKey pubKey = readPu         


        
3条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 16:18

    I suggest you use specific cipher initialization: as an example,

    Cipher cipher = Cipher.getInstance("RSA/ECB/NoPadding");
    

    will work on both. The exception you are getting (BadPaddingException) is occuring because the default cipher initialization padding appears to be different between the desktop JVM and the Android JVM.

提交回复
热议问题