I have to generate two strings with the same hash code. I worked on it, and the maximum that I reached is to change only the first two chars of the string.
public static String same(String s) {
String re = "";
char c = 0;
char ch = 0;
for (int i = 0; i < s.length(); i++) {
c = (char) (s.charAt(0) + 2);
ch = (char) (s.charAt(1) - 31 * 2);
}
String S = new String(new char[] { c, ch });
re = S+ s.substring(2);
return re;
}
How can I do to make it work with all the string.length()??