Delphi DEC library (Rijndael) encryption

前端 未结 3 669
猫巷女王i
猫巷女王i 2021-02-09 07:01

I am trying to use the DEC 3.0 library (Delphi Encryption Compedium Part I) to encrypt data in Delphi 7 and send it to a PHP script through POST, where I am dec

3条回答
  •  走了就别回头了
    2021-02-09 07:24

    You are calling the TCipher.Create(const Password: String; AProtection: TProtection); constructor, which will compute a hash of the password before passing it to the Init method, which performs the standard key schedule of the implemented algorithm. To override this key derivation, use:

    function EncryptMsgData(MsgData, Key: string): string;
    var RCipher: TCipher_Rijndael;
    begin
      RCipher:= TCipher_Rijndael.Create('', nil);
      RCipher.Init(Pointer(Key)^,Length(Key),nil);
      RCipher.Mode:= cmECB;
      Result:= RCipher.CodeString(MsgData, paEncode, fmtMIME64);
      RCipher.Free;
    

    end;

提交回复
热议问题