Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.
Try the following method:
public String xor(String str, String key) {
String result = null;
byte[] strBuf = str.getBytes();
byte[] keyBuf = key.getBytes();
int c = 0;
int z = keyBuf.length;
ByteArrayOutputStream baos = new ByteArrayOutputStream(strB
for (int i = 0; i < strBuf.length; i++) {
byte bS = strBuf[i];
byte bK = keyBuf[c];
byte bO = (byte)(bS ^ bK);
if (c < z - 1) {
c++;
} else {
c = 0;
}
baos.write(bO);
}
try {
baos.flush();
result = baos.toString();
baos.close();
baos = null;
} catch (IOException ioex) {
}
return result;
}
The idea is to convert the string and the key to byte arrays, then you XOR each byte of the string with the corresponding byte from the key, when you "run-out" of key-bytes you just start over from the start of the key ;)
Regards and good luck,
Doron