Home  >  Article  >  Backend Development  >  php determines whether the file exists

php determines whether the file exists

WBOY
WBOYOriginal
2016-07-29 09:10:27966browse

sha1_file Calculates the SHA-1 hash of a text file

<code># 计算文本文件 $file 的 SHA-1 散列:
sha1_file($file);

# 语法
sha1_file(file,raw)

# 参数
file    必需。规定要计算的文件。
raw     可选。布尔值,规定十六进制或二进制输出格式:
        TRUE - 原始 16 字符二进制格式
        FALSE - 默认。32 字符十六进制数</code>

Version: php 4.2.0+

Description: The
sha1_file() function calculates the SHA-1 hash of a file.
sha1_file() function uses American Secure Hash algorithm 1.
Explanation from RFC 3174 - US Secure Hash Algorithm 1: SHA-1 produces a 160-bit output called the message digest. The message digest can be fed into a signature algorithm that generates or verifies the message signature. Signing the message digest instead of the message can improve process efficiency because the size of the message digest is usually much smaller than the message. The verifier of a digital signature must use the same hashing algorithm as the creator of the digital signature.
Returns the calculated SHA-1 hash on success, or FALSE on failure.

md5_file Calculates the MD5 hash of a text file

<code># 计算文本文件 $file 的 MD5 散列:
md5_file($file);

# 语法
md5_file(file,raw)

# 参数
file    必需。规定要计算的文件。
raw     可选。布尔值,规定十六进制或二进制输出格式:
        TRUE - 原始 16 字符二进制格式
        FALSE - 默认。32 字符十六进制数</code>

Version: php 4.2.0+

Description: The
md5_file() function calculates the MD5 hash of a file. The
md5_file() function uses RSA data security, including the MD5 message digest algorithm.
Explanation from RFC 1321 - MD5 message digest algorithm: The MD5 message digest algorithm takes information of any length as an input value and converts it into a 128-bit length "fingerprint information" or "message digest" value to represent This input value has the converted value as the result. The MD5 algorithm is primarily designed for digital signature applications where larger files are encrypted using a public key in a cryptographic system such as RSA. (done by setting a private key) before compressing in a secure manner.

The above introduces PHP to determine whether a file exists, including data security. I hope it will be helpful to friends who are interested in PHP tutorials.

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