欢迎来到传世资源网!
加载中...
正在加载,请耐心等待...
本站为收藏、学习站,如有侵权,请联系管理员删除!

海康ISC平台delphi签名算法.pas

介绍 评论 失效链接反馈

procedure TcsInfoDefine.sigInit(mth,Url:string;var idHttp1:TIdHttp;para:string='');stdcall;
var
  temp,headStr,curTimeStamp,wSigStr,curTime,myContType :string;
  headjo: ISuperobject;
  myD:TDateTime;
  i : Integer;
begin
  myD := now;
  idHttp1.Request.Clear;
  myContType := 'application/json';
  idHttp1.Request.ContentType := myContType;
  idHttp1.Request.CustomHeaders.AddValue('x-ca-signature-headers','x-ca-key,x-ca-timestamp');
  idHttp1.Request.CustomHeaders.AddValue('x-ca-key',Fapp_id);
  idHttp1.Request.Accept := '*/*';
  curTimeStamp := trim(IntToStr(GetJavaTime(myD)));
  idHttp1.Request.CustomHeaders.AddValue('x-ca-timestamp',curTimeStamp);
  curTime := FormatDateTime('yyyy-mm-dd hh:nn:ss',myD);
  idHttp1.Request.CustomHeaders.AddValue('Date',curTime);
  headStr := '{"x-ca-key":"' Fapp_id '","x-ca-timestamp":' curTimeStamp '}';
  headJo := SO(headStr);
  wSigStr := mth #10 '*/*' #10 myContType #10 curTime #10;
  for i := 0 to headJo.AsObject.count-1 do
    wSigStr := wSigStr lowercase(HeadJo.AsObject.GetNames.AsArray[i].AsString ':'
                    trim(headJo.AsObject.GetValues.AsArray[i].AsString)) #10;
  wSigStr := wSigStr Url;
  if trim(para) <> '' then wSigStr := wSigStr '?' para;
  temp := genSigInfo(wSigStr,Fapp_key);
  idHttp1.Request.CustomHeaders.AddValue('x-ca-signature',temp);
end;

function TcsInfoDefine.genSigInfo(const sigStr,sigKey:string):pChar;stdcall;
var
  temp :string;
begin
  temp := THMACUtils<TIdHMACSHA256>.HMAC_Base64(UTF8Encode(sigKey),UTF8Encode(sigStr));
  result := pChar(temp);
end;

下载声明:

本站资源均有第三方用户自行上传分享推荐,非本站自制,仅供玩家做交流学习之用!切勿用于商业用途!游戏作品版权归原作者享有,如有版权问题,请附带版权证明至邮件,本平台将应您的要求删除。
相关推荐:

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复