package com.panzhihua.service_equipment.until;
|
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Service;
|
|
import javax.crypto.Mac;
|
import javax.crypto.spec.SecretKeySpec;
|
import java.nio.charset.StandardCharsets;
|
import java.security.InvalidKeyException;
|
import java.security.NoSuchAlgorithmException;
|
import java.util.Base64;
|
import java.util.Date;
|
import java.util.Map;
|
|
@Slf4j
|
@Service
|
public class MonitorUtil {
|
|
/**
|
* 开门
|
* @return 返回结果
|
* @throws Exception
|
*/
|
public Map getToken() {
|
String url="https://openaisc.sctel.com.cn/video-manage/appToken/getToken";
|
String accesskey = "96a88ccd5f42458b304ca291e710036d";
|
String accessKeySecret = "7b2ef41e0bcf8c94b193c7ec2e10d727";
|
long timestamp = new Date().getTime();
|
String signtype = "SHA1";
|
String params = ""; // 替换为你的请求参数
|
|
String appPolicy = accesskey + accessKeySecret + timestamp + params.substring(0, Math.min(params.length(), 512));
|
|
try {
|
Mac sha1Hmac = Mac.getInstance("HmacSHA1");
|
SecretKeySpec secretKey = new SecretKeySpec(accessKeySecret.getBytes(StandardCharsets.UTF_8), "HmacSHA 1");
|
sha1Hmac.init(secretKey);
|
byte[] hashBytes = sha1Hmac.doFinal(appPolicy.getBytes(StandardCharsets.UTF_8));
|
String sign = Base64.getEncoder().encodeToString(hashBytes);
|
|
System.out.println("Sign: " + sign);
|
} catch (NoSuchAlgorithmException | InvalidKeyException e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
}
|