Delphi HMACSHA256


本文整理自网络,侵删。

 
uses
  IdGlobal, IdHashSHA, IdHMAC, IdHMACSHA1, IdSSLOpenSSL;

function CalculateHMACSHA256(const value, salt: String): String;
var
  hmac: TIdHMACSHA256;
  hash: TIdBytes;
begin
  LoadOpenSSLLibrary;
  if not TIdHashSHA256.IsAvailable then
    raise Exception.Create('SHA256 hashing is not available!');
  hmac := TIdHMACSHA256.Create;
  try
    hmac.Key := IndyTextEncoding_UTF8.GetBytes(salt);
    hash := hmac.HashValue(IndyTextEncoding_UTF8.GetBytes(value));
    Result := ToHex(hash);
  finally
    hmac.Free;
  end;
end;

程序目录下必备文件:
libeay32.dll

ssleay32.dll


了解更多:https://stackoverflow.com/questions/2003194/hmac-sha256-in-delphi

相关阅读 >>

Delphi中获取memo鼠标所在位置的行和列

Delphi xe5实现按android的back键无法退出关闭程序

Delphi fmx 安卓跳转到支付宝付款页面

Delphi 2009 之 tballoonhint

Delphi shellexecute打开文件另类用法

Delphi禁止用鼠标拖动窗口的大小

Delphi xe5 android获取手机联系人,并用listview显示

Delphi 获取含跨域网址的框架网页的源码

Delphi tdictionary 泛型如何排序

Delphi getcomputername() getusername() 获取本机当前用户名

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...