List of utility methods to do xor
long | xor(long x, long y) xor return x ^ y;
|
short | xor(short b1, short b2) xor return (short) (b1 ^ b2); |
String | xor(String key, String input) Simple XOR encryption StringBuilder output = new StringBuilder(); for (int i = 0; i < input.length(); i++) { output.append((char) (input.charAt(i) ^ key.charAt(i % key.length()))); return output.toString(); |
T | xor(T l1, T l2) xor boolean xor = l1 == null ^ l2 == null; if (xor) { return l1 == null ? l2 : l1; return null; |
void | xor32(byte[] a, short aOffset, byte[] b, short bOffset, byte[] result, short offset) xor result[offset] = (byte) (a[aOffset] ^ b[bOffset]); result[(short) (offset + 1)] = (byte) (a[(short) (aOffset + 1)] ^ b[(short) (bOffset + 1)]); result[(short) (offset + 2)] = (byte) (a[(short) (aOffset + 2)] ^ b[(short) (bOffset + 2)]); result[(short) (offset + 3)] = (byte) (a[(short) (aOffset + 3)] ^ b[(short) (bOffset + 3)]); |
long | xorFolding(final long hash, final int shift) xor Folding final long mask = (1L << shift) - 1L; if (shift < 16) { return ((hash >> shift) ^ hash) & mask; } else { return (hash >> shift) ^ (hash & mask); |
void | xorInPlace(byte[] source, int sourceOffset, byte[] destination, int destinationOffset, int size) xor In Place xor(destination, destinationOffset, source, sourceOffset, destination, destinationOffset, size); |
void | xorInt64OverBytesLE(long val, byte[] data, int ofs) xor Int Over Bytes LE int tmp = (int) val; data[ofs] ^= tmp; data[ofs + 1] ^= tmp >>> 8; data[ofs + 2] ^= tmp >>> 16; data[ofs + 3] ^= tmp >>> 24; tmp = (int) (val >>> 32); data[ofs + 4] ^= tmp; data[ofs + 5] ^= tmp >>> 8; ... |
void | XORInto(byte[] dest, byte[] src) Utility function to XOR two byte arrays for (int i = 0; i < dest.length; i++) { dest[i] ^= src[i]; |
void | xorLong(byte[] aBuffer, int aOffset, long aValue) xor Long aBuffer[aOffset] ^= (byte) aValue; aBuffer[aOffset + 1] ^= (byte) (aValue >>> 8); aBuffer[aOffset + 2] ^= (byte) (aValue >>> 16); aBuffer[aOffset + 3] ^= (byte) (aValue >>> 24); aBuffer[aOffset + 4] ^= (byte) (aValue >>> 32); aBuffer[aOffset + 5] ^= (byte) (aValue >>> 40); aBuffer[aOffset + 6] ^= (byte) (aValue >>> 48); aBuffer[aOffset + 7] ^= (byte) (aValue >>> 56); ... |