org.bouncycastle.util.Bytes Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk15to18 Show documentation
Show all versions of bcprov-jdk15to18 Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8.
package org.bouncycastle.util;
/**
* Utility methods and constants for bytes.
*/
public class Bytes
{
public static final int BYTES = 1;
public static final int SIZE = Byte.SIZE;
public static void xor(int len, byte[] x, byte[] y, byte[] z)
{
for (int i = 0; i < len; ++i)
{
z[i] = (byte)(x[i] ^ y[i]);
}
}
public static void xor(int len, byte[] x, int xOff, byte[] y, int yOff, byte[] z, int zOff)
{
for (int i = 0; i < len; ++i)
{
z[zOff + i] = (byte)(x[xOff + i] ^ y[yOff + i]);
}
}
public static void xorTo(int len, byte[] x, byte[] z)
{
for (int i = 0; i < len; ++i)
{
z[i] ^= x[i];
}
}
public static void xorTo(int len, byte[] x, int xOff, byte[] z, int zOff)
{
for (int i = 0; i < len; ++i)
{
z[zOff + i] ^= x[xOff + i];
}
}
}