我在VCL应用中使用外部DLL来计算HMAC sha256哈希,https://www.chilkatsoft.com/delphiDll.asp,我需要一种方法在Delphi 10中为Android做这个,我找不到任何适用于Android的delphi , 这是使用DLL
执行此操作的代码 // Carourel is stopping with a hover on image / slide
// The zoom effect is working
// But when we quit the carousel, cycle of carousel is broken
$('.carousel').hover(
function() {
$(this).find('img').lightzoom();
$(this).carousel('pause');
}
);
更新
我找到了一段代码来获得HMAC SHA256 ..但我无法理解 它是如何工作的,就像上面的代码一样?
function TForm2.HMAC(const s: pwidechar): string;
var
crypt: HCkCrypt2;
success: Boolean;
mac: PWideChar;
begin
crypt := CkCrypt2_Create();
// Any string argument automatically begins the 30-day trial.
success := CkCrypt2_UnlockComponent(crypt,'Anything for 30-day trial.');
if (success <> True) then
begin
Exit;
end;
// The output will be Hex, so set the EncodingMode:
CkCrypt2_putEncodingMode(crypt,'hex');
// Set the hash algorithm:
// Choices are: md5, sha-1, sha256, sha384, sha512, md2, haval
CkCrypt2_putHashAlgorithm(crypt,'sha256');
// Set the HMAC key:
CkCrypt2_SetHmacKeyEncoded(crypt,'my key','ascii');
mac := CkCrypt2__hmacStringENC(crypt,s);
Result := (mac);
CkCrypt2_Dispose(crypt);
end;
答案 0 :(得分:2)
THashSHA2.GetHMAC()
单元中有一个System.Hash
方法。它有一个AHashVersion
参数,您可以将其设置为TSHA2Version.SHA256
(这是默认值)。