Sravani Tedla

Compare Two Crypted Passwords of sugarcrm

Discussion created by Sravani Tedla on Apr 29, 2017
Latest reply on May 2, 2017 by sugar.dennis

Hi Team,


Could you please help for comparing two crypted passwords. Firstly i m explaining the requirement. We are integrating the CRM with third party so in this case the third party team passes us the crypted password to compare with sugarcrm user_hash field in users table.


Below is the explanation.


Below is the CRM password stored in user_hash of the users table


eg : $user_hash_crm=crypt(md5("sravani123"));  i.e $1$lG1BGRlg$fTySUhv1qOe4DqsD.OYuG.


And the third party team also saves the password in crypted format as below


eg :  $user_hash_third=crypt(md5("sravani123")); i.e $1$od6Yu4cO$l0OW8XEcU1kCKPtpEchTU.



Now i needed to compare both the crypted passwords, as crypt generates two different hashes on encryption its failing to compare as below


echo "User Hash Matched";


The above condition fails. Could you guys suggest the way to check whether two hashes are equal or not.


Thanks in advance.