PHP gets the file MD5 and checks to see if it has been modified, _php tutorial

Source: Internet
Author: User
Tags md5 hash

PHP obtains the MD5 of the file and verifies whether it has been modified.


Since it is necessary to determine if the uploaded file has been modified, the MD5 value of the uploaded file needs to be recorded, so here's how to get the MD5 value of the file.

Md5_file ()

The Md5_file () function computes the MD5 hash of the file. The MD5 () function uses RSA data security, including the MD5 message selected passage algorithm. If successful, returns the computed MD5 hash, or False if it fails.

Syntax: MD5 (STRING,RAW)

§ parameter string, required to specify the file to be computed.

§ parameter charlist, optional. Specify hexadecimal or binary output format: TRUE-original 16 character binary format; FALSE-Default. 32 character hexadecimal number.

To store the MD5 hash of the "Test.doc" file:

Now we will detect if "Test.doc" has been changed (that is, 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 to get the file MD5 and check whether it was modified, because it is necessary to determine whether the uploaded file has been modified, you need to record the MD5 value of the uploaded file, so here to say a bit about getting the file MD ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.