getPos method

String getPos(
  1. String s1,
  2. String s2
)

Implementation

String getPos(String s1, String s2) {
  int i, j, temp, temp1, sum;
  String sub1, sub2;
  if (s1.length != s2.length || s1.isEmpty) {
    return "";
  }
  StringBuffer tempo = new StringBuffer();
  for (i = 0; i < s1.length; i = i + 8) {
    sum = 0;
    for (j = i; j < i + 8; j++) {
      sub1 = s1.substring(j, j + 1);
      temp = int.parse(sub1);
      sub2 = s2.substring(j, j + 1);
      temp1 = int.parse(sub2);
      sum = sum + (temp * temp1);
    }
    sum = sum % 2;
    tempo.write(sum.toString());
  }
  return tempo.toString();
}