这是一个来自老猫群一个HMACMD5加密的示例,什么是HMACMD5,请自行脑补。
上示例代码:
program HMACMD5;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.Types,
System.Hash;
var
v: string;
const
key: array [0 .. 15] of Byte = (32, 10, 43, 13, 56, 76, 34, 65, 3, 99, 56,
231, 8, 66, 23, 67);
begin
try
while True do
begin
Writeln('输入一个明文,exit 退出');
Readln(v);
if v = 'exit' then
Break;
v := UpperCase(THashMD5.GetHMAC(TEncoding.Default.GetString(key), v));
Writeln(v);
end;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.