httputil

demo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.uuzu.newbasys.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;

import javax.xml.bind.DatatypeConverter;

/**
* HttpUtilN
*/
public class HttpUtilN {

/**
* 获取时间戳
*/
public static String getTimestamp() {

return DateUtil8.getTimestamp();
}

public static String getQueryString(Map<String, Object> params) {

String result = params.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue())
.reduce((s1, s2) -> s1 + "&" + s2).orElse("");
return result;
}

/**
* 生成签名
*/
public static String generateSign(String str, String key) {

String hash = null;
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update((str + key).getBytes());
byte[] digest = md.digest();
hash = DatatypeConverter.printHexBinary(digest).toLowerCase();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}

return hash;
}
}

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×