Java String Equal areEqualConstantTime(String a, String b)

Here you can find the source of areEqualConstantTime(String a, String b)

Description

are Equal Constant Time

License

Open Source License

Declaration

public static boolean areEqualConstantTime(String a, String b) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static boolean areEqualConstantTime(String a, String b) {
        boolean equal = true;
        if (a.length() != b.length()) {
            equal = false;/* w  w  w. ja v a  2  s .  com*/
        }

        for (int i = 0; i < a.length(); i++) {
            if (a.charAt(i % a.length()) != b.charAt(i % b.length())) {
                equal = false;
            }
        }
        return equal;
    }
}

Related

  1. areEqual(String seq1, String seq2)
  2. areEqual(String str1, String str2)
  3. areEqual(String string1, String string2)
  4. areEqual(String string1, String string2)
  5. areEqual(String thisString, String thatString)
  6. areEqualIgnoreCase(String s1, String s2)
  7. areEqualIgnoreNull(String value1, String value2, boolean caseSensitive)
  8. areEqualLexemes(String l1, String l2)
  9. areEquals(final String origin, final String checkWith)