@Test public void testGeneratingRandomHashReturnsDifferentStringsUponMultipleCalls() { String hash1 = RandomHasher.generateHash(); String hash2 = RandomHasher.generateHash(); assertNotEquals(hash1, hash2); }
public static String generateHash() { Random random = new Random(); StringBuilder builder = new StringBuilder(); int position = 0; while (builder.length() < LENGTH) { position += random.nextInt(CONTENTS.length() * 4) % CONTENTS.length(); builder.append(CONTENTS.charAt(position % CONTENTS.length())); } return builder.toString(); }
RandomHasher { public static String generateHash() { Random random = new Random(); StringBuilder builder = new StringBuilder(); int position = 0; while (builder.length() < LENGTH) { position += random.nextInt(CONTENTS.length() * 4) % CONTENTS.length(); builder.append(CONTENTS.charAt(position % CONTENTS.length())); } return builder.toString(); } }
RandomHasher { public static String generateHash() { Random random = new Random(); StringBuilder builder = new StringBuilder(); int position = 0; while (builder.length() < LENGTH) { position += random.nextInt(CONTENTS.length() * 4) % CONTENTS.length(); builder.append(CONTENTS.charAt(position % CONTENTS.length())); } return builder.toString(); }  }
RandomHasher { public static String generateHash() { Random random = new Random(); StringBuilder builder = new StringBuilder(); int position = 0; while (builder.length() < LENGTH) { position += random.nextInt(CONTENTS.length() * 4) % CONTENTS.length(); builder.append(CONTENTS.charAt(position % CONTENTS.length())); } return builder.toString(); }  static String generateHash(); static String generateRefId(RefLog refLog); }
RandomHasher { public static String generateHash() { Random random = new Random(); StringBuilder builder = new StringBuilder(); int position = 0; while (builder.length() < LENGTH) { position += random.nextInt(CONTENTS.length() * 4) % CONTENTS.length(); builder.append(CONTENTS.charAt(position % CONTENTS.length())); } return builder.toString(); }  static String generateHash(); static String generateRefId(RefLog refLog);  }