Home >Backend Development >PHP Tutorial >PHP gets the md5 of the file and checks whether it has been modified, _PHP tutorial

PHP gets the md5 of the file and checks whether it has been modified, _PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:17:44873browse

PHP gets the md5 of the file and checks whether it has been modified.

Since it is necessary to determine whether the uploaded file has been modified, it is necessary to record the md5 value of the uploaded file, so let’s talk about it here Method to get the md5 value of a file.

md5_file()

The md5_file() function calculates the MD5 hash of a file. The md5() function uses RSA data security, including the MD5 message digest algorithm. Returns the calculated MD5 hash on success, false on failure.

Syntax: md5(string,raw)

§Parameterstring, required, specifies the file to be calculated.

§Parametercharlist, optional. Specifies hexadecimal or binary output format: TRUE - raw 16-character binary format; FALSE - default. 32-character hexadecimal number.

Store the MD5 hash of the "test.doc" file:

Now we will detect if "test.doc" has been changed (i.e. if the MD5 hash has been changed):

The end.

http://www.bkjia.com/PHPjc/889410.html

www.bkjia.com

true
http: //www.bkjia.com/PHPjc/889410.html
TechArticle

PHP gets the md5 of the file and checks whether it has been modified. Since it needs to determine whether the uploaded file has been modified, it needs to be recorded The md5 value of the uploaded file, so let’s talk about getting the file md...

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