Is it possible to create a program to find the collision of 2 different messages with the same first 32 bits using sha1 hashing? I tried using a while loop, but it ran endlessly as though no match were found. I am doing this in Java. These 2 messages must contain "abc123".
My while logic is adding a number to the end of the string, but it fails.
Below is my sha1 hashing (let's just call it) pseudo-code:
public static String sha1Hashing (String message) {
String sha1 = "";
StringBuffer sb = new StringBuffer();
try {
MessageDigest mDigest = MessageDigest.getInstance("SHA1");
byte[] result = mDigest.digest(message.getBytes());
for (int i = 0; i < result.length; i++) {
sb.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1));
}
} catch(NoSuchAlgorithmException e) {
e.printStackTrace();
}
//return first 32 char
sha1 = sb.toString().substring(0,32);
return sha1;
}