We are trying to hash user password using MD5 algorithm, following is our sample code:
import java.security.MessageDigest;
public class EncodingUtil {
private static MessageDigest digester = MessageDigest.getInstance("MD5");
public static String hashPassword(String input) {
if (digester != null) {
digester.reset();
digester.update(input.getBytes());
byte[] messageDigest = digester.digest();
StringBuffer hexString = new StringBuffer();
for (byte element : messageDigest) {
hexString.append(Integer.toHexString(0xFF & element));
}
return hexString.toString();
}
return input;
}
}
But we are getting following error during concurrency test (5 simultaneous users):
java.lang.ArrayIndexOutOfBoundsException
at com.ibm.crypto.provider.MD5.engineUpdate(Unknown Source)
at java.security.MessageDigest$Delegate.engineUpdate(MessageDigest.java:595)
at java.security.MessageDigest.update(MessageDigest.java:346)
So we are getting this error in the following line of code:
digester.update(input.getBytes());
So basically we are using java.security.MessageDigest.update(), which is a SPI and the concrete implementation in WebSphere is com.ibm.crypto.provider.MD5.engineUpdate, where we are having this ArrayIndexOutOfBoundsException.
We are running our application in IBM Websphere 8.5 and Java 8. I tried to find if IBM has any issues related to this [com.ibm.crypto.provider.MD5.engineUpdate()], but not able to find any details. Also not able to find any solution for fixing or getting around this issue.