Delphi XE4下该如何编写呢?为了编译通过,修改TBytes为TIdBytes,但是结果就不ok了。
// Base64编码
function Base64Encode(const Input: TIdBytes): string;
begin
Result := TIdEncoderMIME.EncodeBytes(Input);
end;
// HMACSha1算法
function EncryptHMACSha1(Input, AKey: string): TIdBytes;
var
Key: TIdBytes;
begin
with TIdHMACSHA1.Create do
try
Key := TIdBytes(AKey);
Result := HashValue(TIdBytes(Input));
finally
Free;
end;
end;
uses IdHMACSHA1;
var
bs: TBytes;
begin
with TIdHMACSHA1.Create do
try
Key := ToBytes(HashKey);
bs := HashValue(ToBytes(BaseString));
finally
Free;
end;
end;