I have written a code to generate a MD5 but unfortunately its generating a new MD5 every time for the same string. Can anyone please help.
Code is like below :
public static byte[] getHash(String[] constants)
{
MessageDigest md= MessageDigest.getInstance("MD5");
StringBuilder toBeHashed=new StringBuidler();
for(String c: constants)
{
toBeHashed.append(c);
}
return md.digest(toBeHashed.toString().getBytes());
}
Driver code :
byte[] hash=MyClass.getHash(new String[] {"01L488213P9579","2021-31-31"});
Can anyone please help and let me know if the code I wrote is correct or not? Is it because of the new String array, I am passing every time ?