Are there better alternatives to MD5 checksum for indexing and searching files in a database?

MD5 checksums are not the best option for indexing and searching files in a database due to their susceptibility to collisions and security vulnerabilities. A better alternative would be to use a more secure hashing algorithm such as SHA-256, which provides a higher level of security and reduced risk of collisions.

$file_path = 'path/to/file.txt';
$hash = hash_file('sha256', $file_path);
echo $hash;