?
Solved

Rijndael 128 bit Encryption with Delphi and PHP - 2

Posted on 2011-03-14
10
Medium Priority
?
1,372 Views
Last Modified: 2013-11-19
Hi,
 
       Continue issue from: http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_26402183.html 

       I have same problem as JealousyPrince., I try to compile & test code provide by Slick812  but it does not working on Delphi 2010.  

       Source attached both Php & Delphi project.  Expert please help...

PhpAndD2010Encrypt.zip
0
Comment
Question by:charin1904
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 24

Assisted Solution

by:jimyX
jimyX earned 1000 total points
ID: 35134809
I have updated the Delphi code. Please check and confirm:

DelphiCode-updated.zip
0
 

Author Comment

by:charin1904
ID: 35135613
@jimyX, Thank you very much for your reply.  OK it work correctly while encrypt and decrypt with Delphi 2010 Thanks!.  But when encrypt with Php and try to decrypt with delphi or Encrypt with Delphi and try to decrypt with Php it does not work.

Php Tested script at:
http://208.109.139.169/delphiphp/PhpCode/index.php

Experts can edit and test cript run on website above:
ftp host address:    208.109.139.169
User name:   delphiphp
Password:    Dphp2010
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35135699
I can't access that link!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:charin1904
ID: 35136209
Please try..

To View:
http://www.siambinary.com/delphiphp/PhpCode/index.php

To Edit:
ftp host address:    ftp.siambinary.com
User name:   delphiphp
Password:    Dphp2010
0
 
LVL 34

Assisted Solution

by:Slick812
Slick812 earned 1000 total points
ID: 35139455
greetings charin1904, , I have looked at the code for  function TeaEncrypt( )  in the DelphiCode-updated.zip, , and in the code for  function TeaEncrypt( )  in the original question which I posted, the only change I could see was the pointer reference to the input string -
pTa := PByte(PChar(InStr));
      changed to -
pTa := PByte(PansiChar(InStr));

although I did not go through it line by line. I can not run the 2010 Delphi code, I do not have or use Delphi 2010. . .
When I tested this the PHP and Delphi functions, both encrypt and decrypt using the HEX strings as output, worked in both directions (php to delphi, , and delphi to php), from your comments, the delphi functions work for a delphi only run, and the PHP functions work for a PHP only run, but does not work for a Delphi output to a PHP input run.
If this is the case, I am unsure about how to go about debugging this, since the Delphi code seems unchanged, and the PHP code is likely the same also?

Please consider some encryption Factors, the Keys must be Identical , the Key Arrays in this case, and the verify arrays must be the same.
It looks like they are the same in the code that I have seen, so That may not be it?

I really do not understand why someone would place the key and verify array ini in the form ini function? shouldn't you set the key in the same function you call the TeaEncrypt( ).

Anyway, if you have the time or inclination, you might change the key and verify in each for testing as in -

     for php
$aryK = array(123,210,127,66,190,15,77,95);
$aryVr = array(48,162,251);


      for delphi
procedure TForm1.FormCreate(Sender: TObject);
begin
VAry[0] := 48;
VAry[1] := 162;
VAry[2] := 251;

aryKey[0] := 123;
aryKey[1] := 210;
aryKey[2] := 127;
aryKey[3] := 66;
aryKey[4] := 190;
aryKey[5] := 15;
aryKey[6] := 77;
aryKey[7] := 95;
end;


and then, run the PHP and Delphi  functions TeaEncrypt( ) , with the same input, maybe this input string -
'@@@@@@@@'

as in -
$bo1 = '@@@@@@@@';

, with the same keys, verify and input string, the hex output in both php and delphi should be the same, so compare the two outputs (look at them) and see if they are the same.

if they are not the same you may have to comment out different sections on the php and delphi functions for debugging, and try to isolate which section is causing the variance.
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35139593
Charin, the links are still not accessible.
0
 

Author Comment

by:charin1904
ID: 35139837
Slick812.. Oh... So difficulty..,  for now I think I need only base64_encode and base64_decode function that can run on Delphi 2010 and Php with same output.  

@jimyX,  which link you can't access

http://www.siambinary.com/delphiphp/PhpCode/index.php
or
ftp.siambinary.com
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35140106
Both of them.
I get "time out" for the first, and "connection was reset" for the second.

This variance might be due to nonconformity in the coding between the php and Delphi. That's the only reason that you can get different result for using same key and text (i.e. if it was the same sequence of math and codes the result will always be the same).

Now the point is to know which is correct the php or the Delphi. You may use the Delphi component from the link below and encode/decode any text and match its result by using the code in question to find out which one is in conformity with it.
http://www.cityinthesky.co.uk/opensource/DCPcrypt
0
 

Accepted Solution

by:
charin1904 earned 0 total points
ID: 35140144
I think I got some solution now. Thank you very much for jimyX and Slick812.

---------------------------
I'll delete this question since have my private data.  Thanks again!
0
 

Author Closing Comment

by:charin1904
ID: 35174542
I got some solution now. Thank for all!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This video teaches users how to migrate an existing Wordpress website to a new domain.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question