|
@@ -4,7 +4,6 @@ import org.apache.tomcat.util.codec.binary.Base64;
|
|
|
|
|
|
import javax.crypto.Mac;
|
|
|
import javax.crypto.spec.SecretKeySpec;
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.security.InvalidKeyException;
|
|
@@ -23,10 +22,9 @@ public class DingTalkRobotUtils {
|
|
|
* @param timestamp 时间戳
|
|
|
* @return 完成签名的
|
|
|
* @throws NoSuchAlgorithmException 算法名不对的异常
|
|
|
- * @throws UnsupportedEncodingException 不支持的编码
|
|
|
* @throws InvalidKeyException 非法的关键字
|
|
|
*/
|
|
|
- public static String sign(String secret,Long timestamp) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
|
|
|
+ public static String sign(String secret,Long timestamp) throws NoSuchAlgorithmException, InvalidKeyException {
|
|
|
var stringToSign = timestamp + "\n" + secret;
|
|
|
var mac = Mac.getInstance("HmacSHA256");
|
|
|
mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
|