• Register
0 votes
1.3k views

Problem :

I am new to the socket programming. I have tried to write server and client socket program my server is trying to send a encrypted message to my client.

But I am facing below Exception at byte[] encrypt = cipher2.doFinal(result_Bytes);

javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher
    at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:750)
    at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
    at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313)
    at javax.crypto.Cipher.doFinal(Cipher.java:2086)

How can I fix above error?

8 4 2
2,300 points

1 Answer

0 votes

Solution :

I also had faced a similar issue. The root cause of this issue can vary for different cases.

If you want to decrypt a value which was not encoded properly as shown below.

byte[] encryptedBytes = Base64.decodeBase64(encryptedBase64String);

If your String is misconfigured for any reason or it is encoded wrongly then you may see the error as " Input length must be multiple of 16 when decrypting with padded cipher"

Another case if you are using the encoded string in any url and trying to pass it in the base64Encoded value in url then it will fail. To fix it you should do the URLEncoding and then you can pass in the token, it will surely work.


If you are integrating it with one of the vendors then in that case I found that I had to do the encryption of Base64 using the URLEncoder but after that I need not decode it as it was done internally by a Vendor

5 2 1
4,980 points

Related questions

0 votes
1 answer 13 views
13 views
Problem: Which of the following is NOT a rule that must be followed when naming identifiers? A. Identifiers for constants should use an underscore between words. B. Identifiers should use periods to separate words. C. Identifiers should list the data type at the end of the name. D. Identifiers can contain spaces.
asked Mar 9 ArifulIslam 5.7k points
1 vote
2 answers 77 views
77 views
Problem: I am able to login through webservices api to particular account on 'Oracle on demand'. When i tries to call 'accountQueryPage' method of the stub class (Stub class is generated with help Account.wsdl file), i got the following exception java.net.SocketException: Software caused connection abort: recv failed Can anyone give me some pointers.
asked Mar 27 LizzyM 6.1k points
2 votes
1 answer 25 views
25 views
Problem: I am able to login through webservices api to particular account on 'Oracle on demand'. When i tries to call 'accountQueryPage' method of the stub class (Stub class is generated with help Account.wsdl file), i got the following exception java.net.SocketException: Software caused connection abort: recv failed Can anyone give me some pointers.
asked Mar 24 LizzyM 6.1k points