import java.lang.*;
import java.util.*;
import java.security.MessageDigest;
public class Collisions {
static int N = 50;
static long M
= (long)Math.
pow(2,
32);
public static void main
(String[] args
) { Map
<Long,Long
> results
= new HashMap
<Long,Long
>();
while (true) {
long i
= (long)Math.
floor(Math.
random() * M
); long hash = lsbsha256(N, message);
if (results.containsKey(hash) && results.get(hash) != i) {
hash,
Long.
toString(results.
get(hash
),
16),
message));
} else {
results.put(hash, i);
}
}
}
private static long lsbsha256
(int n,
String string
) { try {
md.update(string.getBytes("UTF-8"));
byte[] bytes = md.digest();
long hash
= 0, mask
= (long)Math.
pow(2,n
) - 1; for (int i = 0; i * 8 <= n; i++) {
long b = (long)(bytes[bytes.length - 1 - i] & 0xFF);
hash = (hash | (b << (8 * i))) & mask;
}
return hash;
return 0L;
return 0L;
}
}
}
aW1wb3J0IGphdmEubGFuZy4qOwppbXBvcnQgamF2YS51dGlsLio7CmltcG9ydCBqYXZhLnNlY3VyaXR5Lk1lc3NhZ2VEaWdlc3Q7CgpwdWJsaWMgY2xhc3MgQ29sbGlzaW9ucyB7CiAgc3RhdGljIGludCAgTiA9IDUwOwogIHN0YXRpYyBsb25nIE0gPSAobG9uZylNYXRoLnBvdygyLCAzMik7CiAgCiAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgTWFwPExvbmcsTG9uZz4gcmVzdWx0cyA9IG5ldyBIYXNoTWFwPExvbmcsTG9uZz4oKTsKICAgIAogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbG9uZyBpID0gKGxvbmcpTWF0aC5mbG9vcihNYXRoLnJhbmRvbSgpICogTSk7CiAgICAgIFN0cmluZyBtZXNzYWdlID0gTG9uZy50b1N0cmluZyhpLCAxNik7CiAgICAgIGxvbmcgaGFzaCA9IGxzYnNoYTI1NihOLCBtZXNzYWdlKTsKICAgICAgCiAgICAgIGlmIChyZXN1bHRzLmNvbnRhaW5zS2V5KGhhc2gpICYmIHJlc3VsdHMuZ2V0KGhhc2gpICE9IGkpIHsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oU3RyaW5nLmZvcm1hdCgiJWQ6ICVzLCAlcyIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc2gsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIExvbmcudG9TdHJpbmcocmVzdWx0cy5nZXQoaGFzaCksIDE2KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZSkpOwogICAgICB9IGVsc2UgewogICAgICAgIHJlc3VsdHMucHV0KGhhc2gsIGkpOwogICAgICB9CiAgICB9CiAgfQogIAogIHByaXZhdGUgc3RhdGljIGxvbmcgbHNic2hhMjU2KGludCBuLCBTdHJpbmcgc3RyaW5nKSB7CiAgICB0cnkgewogICAgICBNZXNzYWdlRGlnZXN0IG1kID0gTWVzc2FnZURpZ2VzdC5nZXRJbnN0YW5jZSgiU0hBLTI1NiIpOwogICAgICBtZC51cGRhdGUoc3RyaW5nLmdldEJ5dGVzKCJVVEYtOCIpKTsKICAgICAgYnl0ZVtdIGJ5dGVzID0gbWQuZGlnZXN0KCk7CiAgICAgIAogICAgICBsb25nIGhhc2ggPSAwLCBtYXNrID0gKGxvbmcpTWF0aC5wb3coMixuKSAtIDE7CiAgICAgIGZvciAoaW50IGkgPSAwOyBpICogOCA8PSBuOyBpKyspIHsKICAgICAgICBsb25nIGIgPSAobG9uZykoYnl0ZXNbYnl0ZXMubGVuZ3RoIC0gMSAtIGldICYgMHhGRik7CiAgICAgICAgaGFzaCA9IChoYXNoIHwgKGIgPDwgKDggKiBpKSkpICYgbWFzazsKICAgICAgfQogICAgICByZXR1cm4gaGFzaDsKICAgICAgCiAgICB9IGNhdGNoIChqYXZhLnNlY3VyaXR5Lk5vU3VjaEFsZ29yaXRobUV4Y2VwdGlvbiBlKSB7CiAgICAgIHJldHVybiAwTDsKICAgIH0gY2F0Y2ggKGphdmEuaW8uVW5zdXBwb3J0ZWRFbmNvZGluZ0V4Y2VwdGlvbiBlKSB7CiAgICAgIHJldHVybiAwTDsKICAgIH0KICB9Cn0K