Share a PHPMD5 function

Source: Internet
Author: User
SugarCRM released a SOAPAPI, but I need to send the MD5 function PHP whose password is compatible with the MD5 format (SugarCRM is built on PHP ). So I wrote a PHP MD5 function to simulate

Recently, I need to use SugarCRM (a good one), an open source CRM implementation to integrate ASP. NET applications.

SugarCRM released a soap api, but I need to send the MD5 function PHP whose password is compatible with the MD5 format (SugarCRM is built on PHP ). So I wrote a PHP MD5 function to simulate

 

Using System. Security. Cryptography;
Using System. Text;

Public sealed class PhpCompatible
{
Public static string Md5Hash (string pass)
{
MD5 md5 = MD5CryptoServiceProvider. Create ();
Byte [] dataMd5 = md5.ComputeHash (Encoding. Default. GetBytes (pass ));
StringBuilder sb = new StringBuilder ();
For (int I = 0; I <dataMd5.Length; I ++)
Sb. AppendFormat ("{0: x2}", dataMd5 [I]);
Return sb. ToString ();
}

 

 

AppendFormat is a difficulty, I found, because I need to pad the hexadecimal number 0. The solution is to remove a string in the format of 2 x. It is hard to understand the functions of common file formats.

There are many PHP applications, and we need a mechanism to interact with them. I hope this function can help you, if you are as described by me

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.