0

この質問にはいくつかのバリエーションがありますが、問題を突き止めることができませんでした。PHP と Delphi で暗号化/暗号化解除しようとしています Delphi でいくつかの設定を見逃していて、UTF-8 と関係があると思います

http://aesencryption.net/を PHP の例として使用して、取得しようとしている結果を示します。イメージ ブロー
パスワード = 123
キー = テスト
128 ビット
uuIikEZSC9Sa1HAt/XKfGQ== に暗号化

Delphi でこれを暗号化解除できるようにしたいhttps://github.com/SeanBDurkin/tplockboxで Delphi XE5 を
使用しています Delphi 内で暗号化/DeCrypt を動作させることはできますが、PHP 暗号化バージョン文字列は異なります

Delphi は 123 を vpdeLlfnxTGrSsa2TpbFvg== に暗号化します

Delphi Encrypt の簡単な例を次に示します。

function TForm3.EncryptV2(plainText: UTF8String): String;
var CipherText : string;
    FLibrary: TCryptographicLibrary;
    FCodec: TCodec;
begin
  mmo1.Lines.Add('plaintext = ' + plainText);

 FLibrary := TCryptographicLibrary.Create(Self);
  try
    FCodec := TCodec.Create(Self);
    try
      FCodec.CryptoLibrary := FLibrary;
      FCodec.StreamCipherId := BlockCipher_ProgId;
      FCodec.BlockCipherId := Format(AES_ProgId, [256]);
      FCodec.ChainModeId := ECB_ProgId; ;
      FCodec.UTF8Password := 'test';
      FCodec.EncryptString( plainText, CipherText, Tencoding.UTF8 );
      FCodec.Burn;

      result := CipherText;
    finally
      FCodec.Free;
    end;
  finally
    FLibrary.Free;
  end;
end;

復号化

function TForm3.DecryptV2(encryptedText: UTF8String): String;
  var plainText : string;
    FLibrary: TCryptographicLibrary;
    FCodec: TCodec;
begin
  FLibrary := TCryptographicLibrary.Create(Self);
  try
    FCodec := TCodec.Create(Self);
    try
      FCodec.CryptoLibrary := FLibrary;
      FCodec.StreamCipherId := BlockCipher_ProgId;
      FCodec.BlockCipherId := Format(AES_ProgId, [256]);
      FCodec.ChainModeId := ECB_ProgId; ;
      FCodec.UTF8Password := 'test';

      mmo1.Lines.Add('Encrypted Text = ' + encryptedText);
      FCodec.DecryptString( plainText, encryptedText,Tencoding.UTF8 );
      mmo1.Lines.Add('DeCrypted Text = ' + plainText);
      result := plainText;
    finally
      FCodec.Free;
    end;
  finally
    FLibrary.Free;
  end;
end;

誰にも提案はありますか?

ここに画像の説明を入力

4

1 に答える 1