I'm guessing you want the file to be unique.
There are several different checksums but to really make sure you need to use at least md5 or even better sha256. Be aware the bigger the file the longer time it will take to calculate the checksum.
There is a comparsion between the different hashes here
https://www.php.net/manual/en/function.hash-file.php
I suggest that you don't do it on the fly but rather use a queue job for this.
Allow the user to upload the file then store it in a temporary folder then check the hash and compare to the files table in the database and if it does not match add it and if it does delete it. Then inform the user.