Home > php教程 > PHP源码 > md5检验文件

md5检验文件

PHP中文网
Release: 2016-05-25 17:09:43
Original
1506 people have browsed it

php代码

<?php
//blog.qita.in
echo &#39;md5检验[目录直接md5目录名称,文件就md5_file整个文件的内容]<br>&#39;;
$filename = "test.txt";
if(is_dir($filename)){
    $md5file = md5($filename);
}else{
    $md5file = md5_file($filename);
}
echo $md5file;
 
//保存原始文件的md5值到md5file.txt文件
//file_put_contents("md5file.txt",$md5file);
 
 
//把原始的md5值与现在的md5值比较就可以知道文件是否被修改
$md5file = file_get_contents("md5file.txt");
if (md5_file("test.txt") == $md5file){
    echo "文件正常";
}else{
    echo "文件已经被修改";
}
?>
Copy after login
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template