public final class HmacUtils extends Object
if (length(K) > blocksize) {
K = H(K) // keys longer than blocksize are shortened
} else if (length(key) < blocksize) {
K += [0x00 * (blocksize - length(K))] // keys shorter than blocksize are zero-padded
}
opad = [0x5c * B] XOR K
ipad = [0x36 * B] XOR K
hash = H(opad + H(ipad + text))
其中:H为散列函数,K为密钥,text为数据,
B表示数据块的字长(the blocksize is that of the underlying hash function)| 构造器和说明 |
|---|
HmacUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
crypt(byte[] key,
byte[] data,
HmacAlgorithms alg) |
static byte[] |
crypt(byte[] key,
byte[] data,
HmacAlgorithms alg,
Provider provider) |
static byte[] |
crypt(byte[] key,
InputStream input,
HmacAlgorithms alg) |
static byte[] |
crypt(byte[] key,
InputStream input,
HmacAlgorithms alg,
Provider provider) |
static Mac |
getInitializedMac(HmacAlgorithms algorithm,
byte[] key) |
static Mac |
getInitializedMac(HmacAlgorithms algorithm,
Provider provider,
byte[] key) |
static byte[] |
md5(byte[] key,
byte[] data) |
static String |
md5Hex(byte[] key,
byte[] data) |
static byte[] |
ripeMD128(byte[] key,
byte[] data) |
static String |
ripeMD128Hex(byte[] key,
byte[] data) |
static byte[] |
ripeMD160(byte[] key,
byte[] data) |
static String |
ripeMD160Hex(byte[] key,
byte[] data) |
static byte[] |
ripeMD256(byte[] key,
byte[] data) |
static String |
ripeMD256Hex(byte[] key,
byte[] data) |
static byte[] |
ripeMD320(byte[] key,
byte[] data) |
static String |
ripeMD320Hex(byte[] key,
byte[] data) |
static byte[] |
sha1(byte[] key,
byte[] data) |
static byte[] |
sha1(byte[] key,
InputStream data) |
static String |
sha1Hex(byte[] key,
byte[] data) |
static String |
sha1Hex(byte[] key,
InputStream data) |
static byte[] |
sha224(byte[] key,
byte[] data) |
static String |
sha224Hex(byte[] key,
byte[] data) |
static byte[] |
sha256(byte[] key,
byte[] data) |
static String |
sha256Hex(byte[] key,
byte[] data) |
static byte[] |
sha384(byte[] key,
byte[] data) |
static String |
sha384Hex(byte[] key,
byte[] data) |
static byte[] |
sha512(byte[] key,
byte[] data) |
static String |
sha512Hex(byte[] key,
byte[] data) |
public static byte[] sha1(byte[] key,
byte[] data)
public static byte[] sha1(byte[] key,
InputStream data)
public static String sha1Hex(byte[] key, byte[] data)
public static String sha1Hex(byte[] key, InputStream data)
public static byte[] md5(byte[] key,
byte[] data)
public static String md5Hex(byte[] key, byte[] data)
public static byte[] sha224(byte[] key,
byte[] data)
public static String sha224Hex(byte[] key, byte[] data)
public static byte[] sha256(byte[] key,
byte[] data)
public static String sha256Hex(byte[] key, byte[] data)
public static byte[] sha384(byte[] key,
byte[] data)
public static String sha384Hex(byte[] key, byte[] data)
public static byte[] sha512(byte[] key,
byte[] data)
public static String sha512Hex(byte[] key, byte[] data)
public static byte[] ripeMD128(byte[] key,
byte[] data)
public static String ripeMD128Hex(byte[] key, byte[] data)
public static byte[] ripeMD160(byte[] key,
byte[] data)
public static String ripeMD160Hex(byte[] key, byte[] data)
public static byte[] ripeMD256(byte[] key,
byte[] data)
public static String ripeMD256Hex(byte[] key, byte[] data)
public static byte[] ripeMD320(byte[] key,
byte[] data)
public static String ripeMD320Hex(byte[] key, byte[] data)
public static Mac getInitializedMac(HmacAlgorithms algorithm, byte[] key)
public static Mac getInitializedMac(HmacAlgorithms algorithm, Provider provider, byte[] key)
public static byte[] crypt(byte[] key,
byte[] data,
HmacAlgorithms alg)
public static byte[] crypt(byte[] key,
byte[] data,
HmacAlgorithms alg,
Provider provider)
public static byte[] crypt(byte[] key,
InputStream input,
HmacAlgorithms alg)
public static byte[] crypt(byte[] key,
InputStream input,
HmacAlgorithms alg,
Provider provider)
Copyright © 2023. All rights reserved.