org.bouncycastle.tsp.ers.ByteArrayComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcpkix-jdk14 Show documentation
Show all versions of bcpkix-jdk14 Show documentation
The Bouncy Castle Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, and certificate generation. This jar contains APIs for JDK 1.4. The APIs can be used in conjunction with a JCE/JCA provider such as the one provided with the Bouncy Castle Cryptography APIs.
package org.bouncycastle.tsp.ers;
import java.util.Comparator;
/**
* Comparator for byte arrays for ERS hash sorting.
*/
class ByteArrayComparator
implements Comparator
{
public int compare(Object l, Object r)
{
byte[] left = (byte[])l;
byte[] right = (byte[])r;
for (int i = 0; i < left.length && i < right.length; i++)
{
int a = (left[i] & 0xff);
int b = (right[i] & 0xff);
if (a != b)
{
return a - b;
}
}
return left.length - right.length;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy