public abstract class TaobaoUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
aesDecrypt(byte[] encryptBytes,
byte[] decryptKey)
AES解密
|
static String |
aesDecrypt(String content,
byte[] decryptKey)
AES解密
|
static String |
aesEncrypt(byte[] content,
byte[] encryptKey)
AES加密
|
static String |
aesEncrypt(String content,
byte[] encryptKey) |
static String |
base64Encode(byte[] src)
.
|
static String |
base64Encode(byte[] src,
String charsetName)
.
|
static String |
byte2hex(byte[] bytes)
把字节流转换为十六进制表示方式。
|
static <V> Map<String,V> |
cleanupMap(Map<String,V> map)
清除字典中值为空的项。
|
static byte[] |
encryptMD5(byte[] data)
对字节流进行MD5摘要。
|
static byte[] |
encryptMD5(String data)
对字符串采用UTF-8编码后,用MD5进行摘要。
|
static String |
getIntranetIp()
获取本机的局域网IP。
|
static List<String> |
getSlideWindows(String input,
int slideSize)
生成滑动窗口
|
static byte[] |
hmacMD5Encrypt(String encryptText,
byte[] encryptKey)
使用 HMAC-MD5 签名方法对对encryptText进行签名
|
static String |
hmacMD5EncryptToBase64(String encryptText,
byte[] encryptKey) |
static String |
hmacMD5EncryptToBase64(String encryptText,
byte[] encryptKey,
int compressLen) |
static Object |
jsonToObject(String json)
把JSON字符串转化为对象结构。
|
static void |
main(String[] args) |
static String |
objectToJson(Object object)
把对象结构转换为JSON字符串。
|
static String |
objectToXml(Object object)
把对象结构转换为XML字符串。
|
static <T extends TaobaoResponse> |
parseResponse(String json,
Class<T> clazz)
把JSON字符串解释为对象结构。
|
static String |
signTopRequest(Map<String,String> params,
String body,
String secret,
String signMethod)
给TOP请求签名。
|
static String |
signTopRequest(RequestParametersHolder requestHolder,
String secret,
String signMethod)
给TOP请求签名。
|
static String |
signTopRequestWithBody(RequestParametersHolder requestHolder,
String body,
String secret,
String signMethod)
给TOP带body体的请求签名,适用于TOP批量API和奇门API的请求签名。
|
public static String signTopRequest(RequestParametersHolder requestHolder, String secret, String signMethod) throws IOException
requestHolder - 所有字符型的TOP请求参数secret - 签名密钥signMethod - signMethod 签名方法,目前支持:空(老md5)、md5, hmac_md5三种IOExceptionpublic static String signTopRequest(Map<String,String> params, String body, String secret, String signMethod) throws IOException
params - 所有字符型的TOP请求参数body - 请求主体内容secret - 签名密钥signMethod - 签名方法,目前支持:空(老md5)、md5, hmac_md5三种IOExceptionpublic static String signTopRequestWithBody(RequestParametersHolder requestHolder, String body, String secret, String signMethod) throws IOException
requestHolder - 所有字符型的TOP请求参数body - 请求body体secret - 签名密钥IOExceptionpublic static byte[] encryptMD5(String data) throws IOException
IOExceptionpublic static byte[] encryptMD5(byte[] data)
throws IOException
IOExceptionpublic static String byte2hex(byte[] bytes)
public static <V> Map<String,V> cleanupMap(Map<String,V> map)
V - 泛型map - 待清除的字典public static Object jsonToObject(String json)
json - JSON字符串public static String objectToJson(Object object)
object - 对象结构public static String objectToXml(Object object)
object - 对象结构public static <T extends TaobaoResponse> T parseResponse(String json, Class<T> clazz) throws ApiException
T - API响应类型json - JSON字符串clazz - API响应类ApiExceptionpublic static String getIntranetIp()
public static String aesEncrypt(String content, byte[] encryptKey) throws SecretException
SecretExceptionpublic static String aesDecrypt(String content, byte[] decryptKey) throws SecretException
content - 待解密的byte[]decryptKey - 解密密钥SecretExceptionpublic static byte[] aesDecrypt(byte[] encryptBytes,
byte[] decryptKey)
throws SecretException
encryptBytes - 待解密的byte[]decryptKey - 解密密钥SecretExceptionpublic static String aesEncrypt(byte[] content, byte[] encryptKey) throws SecretException
content - 待加密的内容encryptKey - 加密密钥SecretExceptionpublic static void main(String[] args) throws SecretException
SecretExceptionpublic static String base64Encode(byte[] src)
src - byte[] inputed stringpublic static String base64Encode(byte[] src, String charsetName) throws UnsupportedEncodingException
src - byte[] inputed stringcharsetName - UnsupportedEncodingExceptionpublic static String hmacMD5EncryptToBase64(String encryptText, byte[] encryptKey, int compressLen) throws SecretException
encryptText - 被签名的字符串encryptKey - 密钥ExceptionSecretExceptionhmacMD5Encrypt(String, byte[])public static String hmacMD5EncryptToBase64(String encryptText, byte[] encryptKey) throws SecretException
encryptText - 被签名的字符串encryptKey - 密钥ExceptionSecretExceptionhmacMD5Encrypt(String, byte[])public static byte[] hmacMD5Encrypt(String encryptText, byte[] encryptKey) throws Exception
encryptText - 被签名的字符串encryptKey - 密钥ExceptionCopyright © 2021. All rights reserved.