16-bit and 32-bit implementation code under php md5

PHP中文网
Release: 2023-02-28 21:18:02
Original
1356 people have browsed it

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加密 
?>
Copy after login

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

The code is as follows:

echo md5("admin",true);//返回16位,不过这是在PHP5里才有。
Copy after login
The output result after testing is garbled. If you have any good code, you can share it.

The above introduces the 16-bit and 32-bit implementation codes of totalmediatheatre5 php md5, including the content of totalmediatheatre5. I hope it will be helpful to friends who are interested in PHP tutorials.


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!