Home  >  Article  >  Backend Development  >  16-bit and 32-bit implementation code under php md5_PHP tutorial

16-bit and 32-bit implementation code under php md5_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:52:33795browse

Copy code The code is as follows:

echo substr(md5("admin"),8,16) ; // 16-bit MD5 encryption
echo "
";
echo md5("admin"); // 32-bit MD5 encryption
?>

The 16-bit MD5 encryption is implemented by intercepting characters with the substr function....

I don’t want to study it in depth :) I need to put my brain power into other key places~~

I made one today PHP connects to the MSSQL database, and the fields in the tables in the database are encrypted using MD5. However, the default MD5 in PHP is 32 bits, which makes it impossible for the login program to use md5 encryption to match the fields in the table. Many people found this confusion when searching online. Later, I found a solution and it was correct, so I recorded it. Come down.

Use substr function to intercept:

substr(md5("admin"),8,16); // 16-bit MD5 encryption

md5("admin"); // 32-bit MD5 encryption

The test results of Script House are as follows:

We compared the results after several md5 of asp
Attachment: If encounter If you want to encrypt an MD5 file but don't know the password, please replace it with this set of encrypted data in the database.

admin---16-bit encryption---7a57a5a743894a0e
admin---32-bit encryption---21232f297a57a5a743894a0e4a801fc3
admin---40-bit encryption---7a57a5a743894a0e4a 801fc343894a0e4a801fc3

substr(md5("admin"),8,16); // 16-bit MD5 encryption is exactly the 32 above, which are the 16 characters starting from the 8th character. So you don’t need to consider the issue of uniqueness. It is correct in itself. Some people on the Internet say that php5 supports
Copy code The code is as follows:

echo md5("admin",true);//return 16-bit, but this is only available in PHP5.

After testing, the output result is garbled code. If you have any good code, you can share it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318927.htmlTechArticleCopy the code as follows: ?php echosubstr(md5("admin"),8,16);//16 Bit MD5 encryption echo "hr"; echomd5("admin");//32-bit MD5 encryption? 16-bit MD5 encryption is implemented by intercepting characters with the substr function...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn