@Test public void itReturnsFalseWhenBytesDontMatch() throws Exception { byte[] a = Hex.decodeHex("000A00BB".toCharArray()); byte[] b = Hex.decodeHex("000A01BB".toCharArray()); assertThat(Subtles.secureCompare(a, b)).isFalse(); }
public static boolean secureCompare(final byte[] a, final byte[] b) { if (a.length != b.length) { return false; } int match = 0; for (int i = 0; i < a.length; i++) { match = match | a[i] ^ b[i]; } return (match == 0); }
Subtles { public static boolean secureCompare(final byte[] a, final byte[] b) { if (a.length != b.length) { return false; } int match = 0; for (int i = 0; i < a.length; i++) { match = match | a[i] ^ b[i]; } return (match == 0); } }
Subtles { public static boolean secureCompare(final byte[] a, final byte[] b) { if (a.length != b.length) { return false; } int match = 0; for (int i = 0; i < a.length; i++) { match = match | a[i] ^ b[i]; } return (match == 0); } private  Subtles(); }
Subtles { public static boolean secureCompare(final byte[] a, final byte[] b) { if (a.length != b.length) { return false; } int match = 0; for (int i = 0; i < a.length; i++) { match = match | a[i] ^ b[i]; } return (match == 0); } private  Subtles(); static boolean secureCompare(final byte[] a, final byte[] b); static boolean secureCompare(final char[] a, final char[] b); static boolean secureCompare(final String a, final String b); }
Subtles { public static boolean secureCompare(final byte[] a, final byte[] b) { if (a.length != b.length) { return false; } int match = 0; for (int i = 0; i < a.length; i++) { match = match | a[i] ^ b[i]; } return (match == 0); } private  Subtles(); static boolean secureCompare(final byte[] a, final byte[] b); static boolean secureCompare(final char[] a, final char[] b); static boolean secureCompare(final String a, final String b);  }