news 2026/11/5 1:10:26

通过winapi获取MD5值

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
通过winapi获取MD5值

type
pTMD5_CTX = ^TMD5_CTX;
TMD5_CTX = record
num:Array[0…1] of ULONG;
buf:Array[0…3] of ULONG;
input:Array[0…64-1] of Byte;
digest:Array[0…16-1] of Byte;
end;
TMD5Init = procedure(Ctx:Pointer);stdcall;
TMD5Update = procedure(Ctx:Pointer; lpBuf:Pointer; nLen:Integer);stdcall;
TMD5Final = procedure(Ctx:Pointer);stdcall;
var
g_IsMd5Load:Boolean;
g_MD5Init:TMD5Init = nil;
g_MD5Update:TMD5Update = nil;
g_MD5Final:TMD5Final = nil;

function WinMd5(str:AnsiString):AnsiString;
var
ctx:TMD5_CTX;
i:Integer;
begin
LodMd5;
Result:=‘’;
if g_IsMd5Load then begin
ZeroMemory(@ctx,sizeof(TMD5_CTX));
g_MD5Init(@ctx);
g_MD5Update(@ctx, @str[1], Length(str));
g_MD5Final(@ctx);
for i:=0 to 15 do begin
Result:=Result+lowercase(Format(‘%.2x’,[ctx.digest[i]]));
end;
end;
end

THANKS FOR
this is sign for MD5:

procedure LodMd5;
var
hMod:Cardinal;
begin
if not g_IsMd5Load then begin
hMod:=LoadLibrary(‘advapi32.dll’);
if hMod<>0 then begin
g_MD5Init:=GetProcAddress(hMod,‘MD5Init’);
g_MD5Update:=GetProcAddress(hMod,‘MD5Update’);
g_MD5Final:=GetProcAddress(hMod,‘MD5Final’);
if (@g_MD5Init<>nil) and (@g_MD5Update<>nil) and (@g_MD5Final<>nil) then begin
g_IsMd5Load:=True;
end;
end;
end;
end;

procedure LodMd5;
var
hMod:Cardinal;
begin
if not g_IsMd5Load then begin
hMod:=LoadLibrary(‘advapi32.dll’);
if hMod<>0 then begin
g_MD5Init:=GetProcAddress(hMod,‘MD5Init’);
g_MD5Update:=GetProcAddress(hMod,‘MD5Update’);
g_MD5Final:=GetProcAddress(hMod,‘MD5Final’);
if (@g_MD5Init<>nil) and (@g_MD5Update<>nil) and (@g_MD5Final<>nil) then begin
g_IsMd5Load:=True;
end;
end;
end;
end;

{{{7BE5084894C301558AC8E0015FE01EB4C2C1DC236C417DF36B988AC2C5C4C41A68ABE92FA2EB1C64A53F4DF061A4E42ABD1B7CE911469BEC64FF51662F4E8480808CA099EB68EC6B89C4085EA353F55CF558A3EB28BA1EB711459C2964FF2B9233A62B68EF66EC2FA020AF286E91F17999E62FA223A32166A8E81278C417B4}}}

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/11/5 1:10:19

西门子S7-1200与三菱Q系列PLC开放式以太网通信实战

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/11/5 1:09:28

工业温度测量系统:ADS122U04IPWR+MK20DX128VFM5硬核组合设计

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/11/5 1:08:08

工业温度测量系统设计:ADS122U04IPWR+STM32F215RE实战指南

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/11/5 1:07:13

基于ADS122U04与PIC18F57K42的高精度RTD测温系统设计

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/11/5 1:06:54

基于ADS122U04与PIC18F87J50的工业级温度测量方案设计

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华
网站建设 2026/11/5 1:05:57

ADS122U04+PIC18LF45K42高精度温度采集方案与实战

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

作者头像 李华