javax.crypto.BadPaddingException:Given final block not properly padded

后端 未结 4 1603
忘了有多久
忘了有多久 2021-02-04 07:50

I have to decrypt a frame on my server. Encrypted frame comes from client device through GPRS on socket.Encryption is done with TripleDes and

4条回答
  •  情书的邮戳
    2021-02-04 07:53

    I've taken a look at your stringToHex method and it seems to be incorrect. Try this one instead:

            StringBuilder rep = new StringBuilder();
            for (byte b : base.getBytes) {
                rep.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
            }
            System.out.println(rep);
    

    Also I found this TripleDes with Padding example; you could try with the algorithm and transformation the example uses.

提交回复
热议问题