You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Delphi XE5升级至11.1后Lockbox 3解密结果不一致问题排查

Delphi 11.1升级后Lockbox 3解密结果异常问题

原有基于Delphi XE5开发、使用Lockbox 3的旧应用,升级至Delphi 11.1后,调用同一Lockbox 3源码中的DecryptSymStr处理同一密文时结果异常:XE5环境下解密得到的Secure3值为'ACK',但在Delphi 11.1中Secure3为空。

经调试追踪发现:

  • TSimpleCodec.DecryptString方法里的Temp.Size在XE5中为6,11.1中为0;
  • 进一步排查TNoNonceDecryptor.End_Decrypt时,发现两个版本的Sentinal值不一致:XE5中为$19B3023F,11.1中为$1CB01D9F;
  • 怀疑问题根源是PByte类型在Delphi XE5与11.1之间存在差异。

调用解密的代码片段

cmdStr := 'JeITyQu7QhWMabJn9qc//lbcSGZqOkDmSBiPTDdNspSfnotu9v5ZfW40VfejWX2lm4wA0ODofvtT0zZ2YxFdZQ==';
Secure3 := DecryptSymStr(cmdStr);

解密核心逻辑片段

Begin_DecryptMemory( Temp);
L := Ciphertext.Size; 
if L > 0 then
  DecryptMemory( Ciphertext.Memory^, L); 
End_DecryptMemory; 
if FisUserAborted then Plaintext := '' 
else 
begin 
  Temp.Position := 0; 
  L := Temp.Size;

关键定义及解密相关函数

Sentinal   := PByte( MemStrmOffset( FEmitBuffer, FBlockLen - 1));

oCodeRDL:   TCodec;

function DecryptSymStr(Value: ansistring): ansistring;
var
   tmpStr: ansistring;
begin
   GenRandomSymKey;
   if AllowEncryption then
   begin
      oCodeRDL.DecryptString(tmpStr, Value);
     Result := tmpStr;
   end
   else
      Result := Value;
end;

procedure GenRandomSymKey;
var
  mGuid: TGUID;
begin
   CreateGuid(mGuid);
   fPassPhrase := '{2F208563-D039-4CE0-9798-87F219674B5A}';
   oCodeRDL.Password := fPassPhrase;
end;

内容的提问来源于stack exchange,提问作者David Kroll

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 14:55:16