利用php失去文件夹的md5校验值
利用php得到文件夹的md5校验值
<?php /** * 工具文件 * 最终目的在于比较两个文件夹的差异, * * 但是本程序只用于得到一个目录的md5校验和,所以需要分别在不同机器上执行,然后比较md5校验和 * * * 1)调用示例 * php get_folder_md5.php /home/temp/2 * * 2)我不想比.svn目录,所以程序中有$entry != ".svn",如果想彻底比较,请删除&& $entry != ".svn" * 3) * @author yyy */ //参数确定 if (count($argv) > 1 ) $dir1 = del_postfix($argv[1]); else die('please input dir'); $global_str = md5('1'); //检查第一个路径有,后者没有或错误的方法。 get_folder_md5($dir1); echo "===========================================================\n"; echo $global_str; echo "\n"; /** * 去除路径末尾的/,并确保是绝对路径 * * @param unknown_type $dir * @return unknown */ function del_postfix($dir) { if (!preg_match('#^/#', $dir)) { throw new Exception('参数必须是绝对路径'); } $dir = preg_replace('#/$#', '', $dir); return $dir; } /** * 递归调用获取md5 * * @param string $dir1 路径1,是标准 */ function get_folder_md5($dir1){ global $global_str; if (is_dir($dir1)) { $arr = scandir($dir1); foreach ($arr as $entry) { if (($entry != ".") && ($entry != "..") && ($entry != ".svn")){ $new = $dir1."/".$entry; //$new是完整文件名或文件夹名 //如果不想显示文件名可以注释下面这句 echo $entry ."\n"; $global_str = md5($global_str . $entry); if(is_dir($new)) { get_folder_md5($new) ; } else { $global_str = md5($global_str . md5_file($new) ); } } } } }

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What is MD5? MD5 Message-DigestAgorithm (English: MD5Message-DigestAgorithm), a widely used cryptographic hash function, can produce a 128-bit (16-byte) hash value (hash value) to ensure complete and consistent information transmission. MD5 was designed by American cryptographer Ronald Linn Rivest and made public in 1992 to replace the MD4 algorithm. The program of this algorithm is specified in the RFC1321 standard. After 1996, the algorithm was proven to have weaknesses and could be cracked. For data requiring high security, experts generally recommend using other algorithms.

This article will explain in detail about PHP calculating the MD5 hash of files. The editor thinks it is quite practical, so I share it with you as a reference. I hope you can gain something after reading this article. PHP calculates the MD5 hash of a file MD5 (MessageDigest5) is a one-way encryption algorithm that converts messages of arbitrary length into a fixed-length 128-bit hash value. It is widely used to ensure file integrity, verify data authenticity and create digital signatures. Calculating the MD5 hash of a file in PHP PHP provides multiple methods to calculate the MD5 hash of a file: Use the md5_file() function. The md5_file() function directly calculates the MD5 hash value of the file and returns a 32-character

This article will explain in detail how PHP calculates the MD5 hash value of a string. The editor thinks it is quite practical, so I share it with you as a reference. I hope you can gain something after reading this article. Calculating the MD5 hash value of a string in PHP Introduction MD5 (Message Digest 5) is a popular cryptographic hash function used to generate fixed-length hash values, often used to protect data integrity, verify file integrity and Create a digital signature. This article will guide PHP developers on how to use built-in functions to calculate the MD5 hash value of a string. md5() function PHP provides the md5() function to calculate the MD5 hash value of a string. This function receives a string parameter and returns a 32-character hexadecimal hash value.

The linux md5 tool is a tool used to calculate and verify the MD5 hash value of a file. MD5 is a commonly used hash algorithm used to generate a unique, fixed-length hash value, usually 128 bits, in Use the md5sum command in the Linux terminal, and its syntax is "md5sum <file path>".

1. Check the consistency of files in the specified directories of the two servers #!/bin/bash############################## #######Check the consistency of files in the specified directories of the two servers################################ ######By comparing the md5 values of the files on the two servers, the purpose of detecting consistency is achieved. dir=/data/webb_ip=192.168.88.10# Traverse all the files in the specified directory and use them as parameters of the md5sum command. Then get the md5 value of all files and write it to the specified file find$dir-typ

Xiaomi has introduced another WLAN mesh system for the global market. After the AC1200 router (approx. 69 euros on Amazon) went on sale in this country, the Xiaomi Mesh System AC1200 has now been announced. The new product has recently been listed on

What is MD5? MD5 (MessageDigestAlgorithm, message digest algorithm), a widely used cryptographic hash function, can produce a 128-bit (16-byte) hash value (hashvalue) to ensure complete and consistent information transmission. The number 5 after it is because it was invented to replace MD4. Simple understanding, its function is to give the file a unique identifier. If we modify the extension of a file, the file may not be opened, but for MD5, there is no change. So for a file, any renaming is useless for md5 verification. MD5 applications: Here are just a few of the more frequent applications I have seen.

What are the similarities and differences between __str__ and __repr__? We all know the representation of strings. Python's built-in function repr() can express objects in the form of strings to facilitate our identification. This is the "string representation". repr() obtains the string representation of an object through the special method __repr__. If __repr__ is not implemented, when we print an instance of a vector to the console, the resulting string may be. >>>classExample:pass>>>print(str(Example()))>>>
