Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8657685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:34:58+00:00 2026-06-12T15:34:58+00:00

I’m using Delphi XE2 with FireMonkey. I have read many other questions about MD5

  • 0

I’m using Delphi XE2 with FireMonkey.

I have read many other questions about MD5 but didn’t find an answer to the issue I have…
I’ve also tested different scripts to generate a MD5 from Delphi:

function MD5(const text: string) : string;
var
  md5 : TIdHashMessageDigest5;
begin
  md5    := TIdHashMessageDigest5.Create;
  Result := LowerCase(md5.HashStringAsHex(text, TEncoding.ANSI));
  md5.Free;
end;

or

function MD5(const text: String) : string;
var
  md5: IMD5;
begin
  md5:= GetMD5;
  md5.Init;
  md5.Update(TByteDynArray(RawByteString(AnsiString(text))), Length(AnsiString(text)));
  Result := LowerCase(md5.AsString);
end;

Both give me the same results… which is often the same I have within PHP:

$md5 = md5($toencode);
$md5 = hash("md5", $toencode);

But the results are different if I use Delphi or PHP, when I request the MD5 of one of these chars: " or '
There are maybe others chars which generate different results but I just find these ones during my tests…

I have tested with many extended ASCII characters and have the same MD5…

So, I don’t understand why I have differences with few of them (" or ' ), and I’d like to know if there’s a way to always generate the PHP MD5 result from Delphi, whatever the chars are.

Any idea?

For instance:

with Delphi:

“: b15835f133ff2e27c7cb28117bfae8f4

‘: 3590cb8af0bbb9e78c343b52b93773c9

with PHP:

“: 3bd864034f446da13581129bb17f9191

‘: 024c94d6e03b6f67a86b952b914816c7

Formalizing this question.. I’ve find the answer… BTW, I post it as others may have the same issue…

" and ' are escaped in PHP… so, within Delphi, I have to encode \" and \'… if you think I have forgotten chars or if you want to add some details, do not hesitate…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:34:59+00:00Added an answer on June 12, 2026 at 3:34 pm

    The PHP hash function implements MD5 perfectly well.

    The following PHP:

    $md5 = hash("md5", "\"");
    echo "\":&nbsp;&nbsp;", $md5, "<br/>";
    $md5 = hash("md5", "'");
    echo "':&nbsp;&nbsp;", $md5, "<br/>";
    $md5 = hash("md5", "\\\"");
    echo "\\\": ", $md5, "<br/>";
    $md5 = hash("md5", "\\'");
    echo "\\': ", $md5, "<br/>";
    

    results in this output:

    ":  b15835f133ff2e27c7cb28117bfae8f4
    ':  3590cb8af0bbb9e78c343b52b93773c9
    \": 3bd864034f446da13581129bb17f9191
    \': 024c94d6e03b6f67a86b952b914816c7
    

    So, the top two values are what you get from your Delphi code, and the same values that Ignacio obtained from Python. So, there’s absolutely no reason to believe that the PHP MD5 code is at fault. And the bottom two values are what your PHP code is returning.

    Which leaves us to conclude that you are feeding your Delphi code different input from that which you feed to your PHP code. If you feed them both the same input, you will get the same output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I know there's a lot of other questions out there that deal with this
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.