Home >Backend Development >PHP Tutorial >php custom complex MD5 encryption function

php custom complex MD5 encryption function

高洛峰
高洛峰Original
2016-11-29 15:22:351465browse

This article first customizes the complex MD5 encryption function to encrypt the password, and then encrypts it by the system's md5 encryption program. Let me introduce the implementation method.

Although the ciphertext of md5 is limited, its ciphertext is limited. The number is 6.3340286662973277706162286946812e+49. If you don’t feel this number, you can imagine that 100 million raised to the fifth power multiplied by tens of millions is enough.

I have been exposed to many programs before, when I was a rookie hacker ..., most program encryption methods are "md5", and it is pure encryption. Originally, this was not wrong. I thought that the md5 algorithm had not been cracked after all. However, with the collection of characteristic strings, the use of pure md5 encryption has become more and more difficult. Dangerous.

When writing programs, I usually add a characteristic string and then MD5, thinking that it is foolproof, but today I found that cmd5 can actually crack this encryption method. Of course, the prerequisite is to know the characteristic string. Although mine is more complicated, but Out of precaution, the encryption function is still complicated.

php The custom complex MD5 encryption function code is as follows:

function md123($sstr)

{

$md_asc=””;

$mds= md5(“qwEqw”.$sstr.”2ddsdf”);

$mds=md5(“rtrTtyr”.$mds.”zcv34r”);

for($i=1;$i< strlen($mds) ;$i++){

$md_asc.=168/ord(substr($mds,$i,1));

}//Open source code phpfensi.com

return md5($md_asc);

}

In this way, password security is further improved through random strings and ascii. When passing ord, a simple 1 has been converted into characters:

1.73195876288662.94736842105261.66336633663373.1111

11111 11113.23076923076923.16981132075471.731958762

88661.683.42857142857142.94736842105261.681.681.6470

5882352943.11111111111111.66336633663372.94 736842

105263.42857142857141.66336633663373. 1698113207547

3.16981132075473.11111111111111 .69696969696971.681.7

1428571428573.16981132 075471.71428571428573.294117

64705881.681.647 05882352941.69696969696971.64705882

352946ccc2eceada95b64bc7f55c07c2a6af6

It will be safe if you perform MD5 encryption in this way.

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