基本信息
源码名称:海康ISC平台delphi签名算法.pas
源码大小:0.01M
文件格式:.pas
开发语言:Pascal
更新时间:2020-11-19
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
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;
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;