Home > php教程 > PHP源码 > php-md5变换算法之密文分割MD5

php-md5变换算法之密文分割MD5

PHP中文网
Release: 2016-05-25 17:14:42
Original
1362 people have browsed it

php代码

<?php 
//把密文分割成两段,每段16个字符 
function md5_2_1($data) 
{ 
//先把密码加密成长度为32字符的密文 
$data = md5($data); 
//把密码分割成两段 
$left = substr($data, 0, 16); 
$right = substr($data, 16, 16); 
//分别加密后再合并 
$data = md5($left).md5($right); 
//最后把长字串再加密一次,成为32字符密文 
return md5($data); 
} 

//把密文分割成32段,每段1个字符 
function md5_2_2($data) 
{ 
$data = md5($data); 
//循环地截取密文中的每个字符并进行加密、连接 
for ($i = 0; $i < 32; $i++) { 
$data .= md5($data{$i}); 
} 
//这时$data长度为1024个字符,再进行一次MD5运算 
return md5($data); 
} 
?>
Copy after login

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