The 16-bit and 32-bit implementation codes of MD5 encryption in PHP. Many people were confused about this when searching on the Internet. Later, I found a solution and it was correct, so I recorded it.
The code is as follows:
<?php echo substr(md5("admin"),8,16); // 16位MD5加密 echo "<hr>"; echo md5("admin"); // 32位MD5加密 ?>
16 Bit MD5 encryption is implemented by intercepting characters using the substr function....
I don’t want to delve into it any more :) I have to put my brainpower into other key places~~
Today I made a php link to the mssql database, and the fields in the tables in the database Use MD516 encryption. 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 were confused about this when searching online. Later, I found a solution and it was correct, so I recorded it. Come down.
Use the substr function to intercept:
substr(md5("admin"),8,16); // 16-bit MD5 encryption
md5("admin"); // 32-bit MD5 encryption
The results tested by this site are as follows:
Let’s compare the results of several md5 files in asp. Attachment: If you encounter an MD5 encrypted file and you 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---7a57a5a743894a0e4a801fc3438 94a0e4a801fc3
substr(md5("admin"),8,16) ; // 16-bit MD5 encryption is exactly the 32 above as the 16 characters starting from the 8th character. So you don’t need to consider the issue of uniqueness. It is correct in itself. Someone on the Internet said that php5 supports
echo md5("admin",true);//返回16位,不过这是在PHP5里才有。