Home > Backend Development > PHP Tutorial > PHP md5 encryption and decryption algorithms and tools (with code)

PHP md5 encryption and decryption algorithms and tools (with code)

PHP中文网
Release: 2023-02-28 22:12:02
Original
10904 people have browsed it

The example in this article describes the encryption and decryption method implemented by php md5. The MD5 algorithm is generally used in situations where data is encrypted, such as user login passwords for websites. Students who are interested in MD5 can refer to it.

1. What is MD5?
Message Digest Algorithm MD5 (Chinese called Message Digest Algorithm Version 5) is a hash function widely used in the field of computer security to provide message integrity protection. Currently, user passwords in PHP website development are encrypted using MD5.

Second.md5 encryption algorithm code

//加密
<body style="color:green;font-size:28px;background:black;font-family:Verdana, sans-serif;">
<?php error_reporting(0);?>
<form name="c" action="<?php echo $_SERVER[&#39;PHP_SELF&#39;];?>" method="get">
Input your text:
<input type="text" name="c" />
<button type="submit" value="Submit" style="color:green;font-size:28px;background:black;">Creat!</button>
</form>
</body>
<?php
//hash encode:
if($c=$_GET[&#39;c&#39;])echo &#39;Roger!Your MD5 code is:<br>&#39;.md5($c).&#39;(32bit)<br>&#39;.substr(md5($c),8,16).&#39;(16bit)&#39;;//截取8到24就是16位的hash,便于储存
?>
Copy after login

Can 3.md5 be decrypted or cracked?

The encryption algorithm of MD5 is an irreversible encryption algorithm and cannot be decrypted in theory. The encryption principle of MD5 is a hash algorithm, which is also called a hash algorithm. The data structure of computer majors includes the knowledge of hash tables. For example, if 10 is divided by 3, the remainder is one, and if 4 is divided by 3, the remainder is also one, but if the remainder is one, you don’t know which number it is. So md5 cannot be decrypted. Even the person who designed this encryption algorithm doesn’t know. But how is your password verified? This is because the same password must be the same after encryption. You will know whether your password is correct only after you enter the password and encrypt it. In other words, only you know your password. This is also the reason why the QQ password can only be reset but not retrieved. (Reference: Can php md5 encryption be cracked? )
But if a simple MD5 password is used, it can still be cracked by brute force. They do this by continuously saving various codes and passwords and then matching them to finally get the password. However, complex passwords are still a bit difficult. (php md5 decryption code sharing (with interface, available for personal testing) )

Four. Reset password method through MD5

Since the MD5 encryption algorithm is an irreversible encryption algorithm, when you forget If the password is lost, you can reset the password or overwrite the password. For example, if you forget the website backend password, you can use php Chinese websiteMD5 online encryption tool to enter the password you want to encrypt, then generate an MD5 ciphertext string, and overwrite this ciphertext string in the original database user table. MD5 ciphertext is enough.

PHP md5 encryption and decryption algorithms and tools (with code)

The above introduces the encryption method implemented by PHP md5, including the relevant content of md5 decryption. I hope it will be helpful to friends on the PHP Chinese website.

Related articles:
Can php md5 be decrypted?

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template