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 6005557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:24:51+00:00 2026-05-23T01:24:51+00:00

I am trying to match a md5 has (generated through php) to its original

  • 0

I am trying to match a md5 has (generated through php) to its original value in a SQLExpress database.

I am using the following function in my SQL query

master.sys.fn_varbintohexsubstring(0, HASHBYTES('MD5', 'ID'), 1, 0)

Where ‘ID’ is the field in the database.

However they both seem to return different values for the md5 hash. I have been using ‘12290’ as a static value to test this.

php md5() returns: 0bd81786a8ec6ae9b22cbb3cb4d88179

The following SQL Statement returns the same output:

DECLARE @password VARCHAR(255)
SET @password = master.sys.fn_varbintohexsubstring(0, HASHBYTES('MD5', '12290'), 1, 0)
SELECT @password

Yet when I run the following statement from the table:

SELECT ID,  master.sys.fn_varbintohexsubstring(0, HASHBYTES('MD5', CONVERT(NVARCHAR(255), ID)), 1, 0) AS temp
FROM Clients
ORDER BY ID ASC

The ‘temp’ value matching to the ‘ID’ value of 12290 returns: 1867dce5f1ee1ddb46ff0ccd1fc58e03

Any help on the matter would be much appreciated!

Thanks

  • 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-05-23T01:24:52+00:00Added an answer on May 23, 2026 at 1:24 am

    I don’t have SQL server to test this on, but the CONVERT command might be creating the NVARCHAR with 240-odd trailing blanks (as you have specified NVARCHAR(255))

    Try setting the NVARCHAR to the length of the ID to test:

    ARE @password VARCHAR(255)
    SET @password = master.sys.fn_varbintohexsubstring(0, HASHBYTES('MD5', CONVERT(NVARCHAR(5), '12290')), 1, 0)
    SELECT @password
    

    Try with different lengths in the CONVERT – is there any difference?

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

Sidebar

Related Questions

I'm trying to compare an MD5 checksum generated by PHP to one generated by
I'm trying to match elements with a name that is 'container1$container2$chkChecked' , using a
I'm currently using this code for md5 hashing in Delphi 7: function MD5(const fileName
I'm trying to get unique IDs for object instances in PHP 5+. The function,
I am trying to match a parent in the following HTML <tbody> <tr id=group-1
I am trying to match and loop through files with extensions .txt .h .py.
I am trying to match floating-point decimal numbers with a regular expression. There may
I'm trying to match the parts of a version number (Major.Minor.Build.Revision) with C# regular
I am trying to match multiple CSS style code blocks in a HTML document.
I'm trying to match SHA1's in generic text with a regular expression. Ideally I

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.