upload - Use MD5 or random for file naming? -
Which method is better for file naming?
Method 1:
- MD5 A string / file (whatever), we use the [0- 9A-Z] letters with 32 string perpendiculars
- (10 + 26) ^ 32 combination
- To generate a set of random characters Use PHP [0-9-zA-Z] 32 string length characters
- (10 + 26 + 26) ^ 32 combination
Obviously method 2 There is more combination and randomness, but why people do not use method 2, but Use Method 1?
I can think of two reasons:
- something File systems (such as VFAT, FAT32) do not support case-sensitive file names.
- MD5 is the value beyond being random in the hash, meaning that the file can serve fingerprint / checksum. It can help you:
- Verify that the contents of the file have not been changed since it was created;
- Prevent duplicated content from being stored.
Comments
Post a Comment