C
C
CloudMonster2014-04-08 20:21:01
PHP
CloudMonster, 2014-04-08 20:21:01

What is the hash of a file?

Hello!
I am developing a file storage.
When uploading a file to the server, I want to make such a scheme.
1. PHP uploading a file to the server
- uploading a file to the server, the file name will be the hash of the file.
- the original file name, extension, hash and username are entered into the database.
In my understanding of the hash file is the name of the file in md5. But this seems to be a misunderstanding.
How to find the hash of a file?
And does the hash of a file change if the contents of the file change?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Litvinov, 2014-04-08
@CloudMonster

sha1_file , md5_file
hash changes when file contents change

S
Snewer, 2014-04-08
@Snewer

File content hash

F
friogenn, 2014-04-08
@friogenn

A hash is the result of converting arbitrary length data into fixed length data.
md5 is a hash function, yes.
In an ideal world, when the data changes, the hash also changes, but collisions happen in hash functions (the same hash for different inputs).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question