Hello am trying to encrypt my strings in delphi I already encrypted my needed strings in php but am having a little trouble getting the matching string from my delphi test application below is the php code am using to encrypt on website then following code is my delphi app that am trying to recreate the same code as php so I can generate the same encode to match them can anyone help or maybe give a better solution?

php code:

       function encrypt($text, $salt)
       {
         return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_RAND))));
       }

Delphi code :

procedure TMainForm.GoBtnClick(Sender: TObject);
var
 Cipher : TLbRijndael;
 Encode64 : TIdEncoderMIME;
begin
  PlainText := InPutEdit.Text;
  KeyStr := edtPassphrase.Text;
  //
  Cipher := TLbRijndael.Create(nil);
  Encode64 := TIdEncoderMIME.Create(nil);
   try
    Cipher.KeySize := ks128;
    Cipher.CipherMode := cmECB;
    Cipher.GetKey(KeyStr);
    //
    StaticText1.Caption := Trim(Encode64.EncodeString(Cipher.EncryptString(PlainText)));
  finally
    Cipher.Free;
    Encode64.Free;
  end;
end;

I did notice that site but still all the code there did not work so was trying to do it myself but need some more help.

that did the trick ty pritaeas :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.