Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have an application which was built in .Net and using membership authentication to saved password in database. I need to copy that same logic and make another system in PHP.

In PHP i am using below code to trying to replicate same logic -

base64_encode(hash_hmac('sha256', base64_decode($salt) . iconv('UTF-8', 'UTF-16LE', $password), base64_decode($salt), true));

But PHP has been generating different hash password by using above logic. Below are results of both programming languages -

Example 1 -
Security stamp - 59b1c5eb-06b4-4dff-8be9-384be4eca037
Entered Password - Testing123#

Example 2 -
Security stamp - 58346e08-a22a-4967-a7f0-2eff666f862a
Entered Password - Test456@

And the results are -

ASP.Net (with C#)
Generated Hash Password - AMeK7Q05tOD+Ge3LcNJmrzvdUz7e1ni/MgKUEdbNXFPkldfHUhf7B3pusxJOj5kHXA==

Generated Hash Password - AKnUILkPRtF/RAGqzmjducGBZfz+DpRQ5+ZFwtQUBWFVe5CybjX/GJixdAXZ6dzt1Q==

PHP
Generated Hash Password - g8rAF1hZDCTyTxaGCPdYVFZp8e+E4zWV7u/0TfSVNfg=
Generated Hash Password - O3QnJVSoVduwNUX80Z9HWnBCLZwbxKE00K2D/oXCSvU=

So as you see .Net has generated 68 characters Hash password and PHP has 44 chars. Even none of things were matched together.

Can someone please advice how this will be make in PHP and generate same password did by ASP.Net membership. Thanks!

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.