public class HashUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
MURMUR_SEED |
| Constructor and Description |
|---|
HashUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
crc32AsInt(byte[] input)
对输入字符串进行crc32散列返回int, 返回值有可能是负数.
|
static int |
crc32AsInt(String input)
对输入字符串进行crc32散列返回int, 返回值有可能是负数.
|
static long |
crc32AsLong(byte[] input)
对输入字符串进行crc32散列,与php兼容,在64bit系统下返回永远是正数的long
Guava也有crc32实现, 但返回值无法返回long,所以统一使用JDK默认实现
|
static long |
crc32AsLong(String input)
对输入字符串进行crc32散列,与php兼容,在64bit系统下返回永远是正数的long
Guava也有crc32实现, 但返回值无法返回long,所以统一使用JDK默认实现
|
static byte[] |
generateSalt(int numBytes)
用SecureRandom生成随机的byte[]作为salt.
|
static byte[] |
md5File(InputStream input)
对文件进行md5散列,被破解后MD5已较少人用.
|
static long |
murmur128AsLong(byte[] input)
对输入字符串进行murmur128散列, 返回值可能是负数
|
static long |
murmur128AsLong(String input)
对输入字符串进行murmur128散列, 返回值可能是负数
|
static int |
murmur32AsInt(byte[] input)
对输入字符串进行murmur32散列, 返回值可能是负数
|
static int |
murmur32AsInt(String input)
对输入字符串进行murmur32散列, 返回值可能是负数
|
static byte[] |
sha1(byte[] input)
对输入字符串进行sha1散列.
|
static byte[] |
sha1(byte[] input,
byte[] salt)
对输入字符串进行sha1散列,带salt达到更高的安全性.
|
static byte[] |
sha1(byte[] input,
byte[] salt,
int iterations)
对输入字符串进行sha1散列,带salt而且迭代达到更高更高的安全性.
|
static byte[] |
sha1(String input)
对输入字符串进行sha1散列, 编码默认为UTF8.
|
static byte[] |
sha1(String input,
byte[] salt)
对输入字符串进行sha1散列,带salt达到更高的安全性.
|
static byte[] |
sha1(String input,
byte[] salt,
int iterations)
对输入字符串进行sha1散列,带salt而且迭代达到更高更高的安全性.
|
static byte[] |
sha1File(InputStream input)
对文件进行sha1散列.
|
public static final int MURMUR_SEED
public static byte[] sha1(byte[] input)
public static byte[] sha1(String input)
public static byte[] sha1(byte[] input,
byte[] salt)
public static byte[] sha1(String input, byte[] salt)
public static byte[] sha1(byte[] input,
byte[] salt,
int iterations)
generateSalt(int)public static byte[] sha1(String input, byte[] salt, int iterations)
generateSalt(int)public static byte[] generateSalt(int numBytes)
numBytes - salt数组的大小public static byte[] sha1File(InputStream input) throws IOException
IOExceptionpublic static byte[] md5File(InputStream input) throws IOException
IOExceptionpublic static int crc32AsInt(String input)
public static int crc32AsInt(byte[] input)
public static long crc32AsLong(String input)
public static long crc32AsLong(byte[] input)
public static int murmur32AsInt(byte[] input)
public static int murmur32AsInt(String input)
public static long murmur128AsLong(byte[] input)
public static long murmur128AsLong(String input)
Copyright © 2018. All rights reserved.