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
Method 2:

  • 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:

  1. something File systems (such as VFAT, FAT32) do not support case-sensitive file names.
  2. 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

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -