This method returns a string obtained by XOR-ing two strings of same length passed a method parameters @param String a and b are string objects which will be XORed and are to be of same length @return String object obtained by XOR operation on String a and String b
(String a, String b)
| 1119 | * @return String object obtained by XOR operation on String a and String b |
| 1120 | * */ |
| 1121 | private String xor(String a, String b) { |
| 1122 | a = hexToBin(a); |
| 1123 | b = hexToBin(b); |
| 1124 | StringBuilder ans = new StringBuilder(); |
| 1125 | for (int i = 0; i < a.length(); i++) { |
| 1126 | ans.append((char) (((a.charAt(i) - '0') ^ (b.charAt(i) - '0')) + '0')); |
| 1127 | } |
| 1128 | ans = new StringBuilder(binToHex(ans.toString())); |
| 1129 | return ans.toString(); |
| 1130 | } |
| 1131 | |
| 1132 | /** |
| 1133 | * This method returns addition of two hexadecimal numbers passed as parameters and moded with |