Reformat all files in the project according to java conventions.
This commit is contained in:
@@ -8,28 +8,28 @@ public interface Hashing {
|
||||
public ThreadLocal<MessageDigest> md5Holder = new ThreadLocal<MessageDigest>();
|
||||
|
||||
public static final Hashing MD5 = new Hashing() {
|
||||
public long hash(String key) {
|
||||
return hash(SafeEncoder.encode(key));
|
||||
}
|
||||
public long hash(String key) {
|
||||
return hash(SafeEncoder.encode(key));
|
||||
}
|
||||
|
||||
public long hash(byte[] key) {
|
||||
try {
|
||||
if (md5Holder.get() == null) {
|
||||
md5Holder.set(MessageDigest.getInstance("MD5"));
|
||||
}
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalStateException("++++ no md5 algorythm found");
|
||||
}
|
||||
MessageDigest md5 = md5Holder.get();
|
||||
public long hash(byte[] key) {
|
||||
try {
|
||||
if (md5Holder.get() == null) {
|
||||
md5Holder.set(MessageDigest.getInstance("MD5"));
|
||||
}
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalStateException("++++ no md5 algorythm found");
|
||||
}
|
||||
MessageDigest md5 = md5Holder.get();
|
||||
|
||||
md5.reset();
|
||||
md5.update(key);
|
||||
byte[] bKey = md5.digest();
|
||||
long res = ((long) (bKey[3] & 0xFF) << 24)
|
||||
| ((long) (bKey[2] & 0xFF) << 16)
|
||||
| ((long) (bKey[1] & 0xFF) << 8) | (long) (bKey[0] & 0xFF);
|
||||
return res;
|
||||
}
|
||||
md5.reset();
|
||||
md5.update(key);
|
||||
byte[] bKey = md5.digest();
|
||||
long res = ((long) (bKey[3] & 0xFF) << 24)
|
||||
| ((long) (bKey[2] & 0xFF) << 16)
|
||||
| ((long) (bKey[1] & 0xFF) << 8) | (long) (bKey[0] & 0xFF);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
public long hash(String key);
|
||||
|
||||
Reference in New Issue
Block a user