mysql / file hash question -


I would like to write a script that crosses a file tree, calculates a hash for each file, and Includes a hash with a SQL table together with a file path, such as I can then query and search for similar files. What is the recommended hash function or command like a tool to make a hash, which is unlikely to be similar to different files? Thanks B

You can use md5 hash or sha1

  Function process_dir ($ path) {if ($ handle = opendir ($ path)) {while (false! == ($ file = readdir ($ handle))) {if ($ file! = "." & Amp; $ File! = "..") {if (is_dir ($ path. "/". $ File)) {process_dir ($ path. "/". $ File); } Else {// you can change sh1 // from MD5, you can put that hash in the database $ hash = MD5 (file_gate_content ($ path /. $ File))}}} closed ( $ Handle);}}  

If you make changes to Windows, then slash on backslash.


Comments