enjoy 3.3 release ^_^
This commit is contained in:
@@ -20,10 +20,22 @@ import java.security.MessageDigest;
|
||||
|
||||
public class HashKit {
|
||||
|
||||
public static final long FNV_OFFSET_BASIS_64 = 0xcbf29ce484222325L;
|
||||
public static final long FNV_PRIME_64 = 0x100000001b3L;
|
||||
|
||||
private static final java.security.SecureRandom random = new java.security.SecureRandom();
|
||||
private static final char[] HEX_DIGITS = "0123456789abcdef".toCharArray();
|
||||
private static final char[] CHAR_ARRAY = "_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
|
||||
|
||||
public static long fnv1a64(String key) {
|
||||
long hash = FNV_OFFSET_BASIS_64;
|
||||
for(int i=0, size=key.length(); i<size; i++) {
|
||||
hash ^= key.charAt(i);
|
||||
hash *= FNV_PRIME_64;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static String md5(String srcStr){
|
||||
return hash("MD5", srcStr);
|
||||
}
|
||||
|
Reference in New Issue
Block a user