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['PHP_SELF'];?>" 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['c'])echo 'Roger!Your MD5 code is:<br>'.md5($c).'(32bit)<br>'.substr(md5($c),8,16).'(16bit)';//截取8到24就是16位的hash,便于储存 ?>
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.
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?