Php md5 16-bit and 32-bit implementation code

Source: Internet
Author: User

Copy codeThe Code is as follows:
<? Php
Echo substr (md5 ("admin"), 8, 16); // 16-bit MD5 Encryption
Echo "Echo md5 ("admin"); // 32-bit MD5 Encryption
?>

The 16-bit MD5 encryption is achieved by intercepting characters using the substr function ....

I don't want to study it in depth. I need to put my mental power in other key areas ~~

Today, I made a php link to the mssql database. The fields in the table in the database are encrypted using MD5 sixteen. However, the MD5 value in php is 32 bits by default. As a result, the login program cannot use md5 encryption to match the fields in the Table. Many people may find this problem on the Internet and find a solution, if it is correct, record it.

Use the substr function to intercept:

Substr (md5 ("admin"), 8, 16); // 16-bit MD5 Encryption

Md5 ("admin"); // 32-bit MD5 Encryption

The results of the script home test are as follows:

We compare the results of several md5 values in asp.
Appendix: If you encounter an MD5 encrypted file and do not know the password, replace this set of encrypted data in the database.

Admin --- 16-bit encryption --- 7a57a5a743894a0e
Admin --- 32-bit encryption --- 21232f297a57a5a743894a0e4a801fc3
Admin --- 40-bit encryption --- 7a57a5a743894a0e4a801fc343894a0e4a801fc3

Substr (md5 ("admin"), 8, 16); // The 16-bit MD5 encryption is the 16 characters starting from 8th characters. Therefore, you do not need to consider the uniqueness issue. It is correct. Some people on the Internet say that php5 supports
Copy codeThe Code is as follows:
Echo md5 ("admin", true); // return 16 bits, but this is only available in PHP5.

The output result is garbled. If you have any good code, share it.

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.