Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我计划在服务器上托管图像,并希望使用相同类型的文件命名加密机制。它只是一个哈希吗?
是的。
$filename = md5($_SERVER['REQUEST_URI'].$_SERVER['REMOTE_ADDR'].rand(50000000, 900000000000)).$ext;
这只是一个哈希。如果你有字符 a-zA-Z0-9 并选择一个只有 6 个字符长的哈希,你会得到 61,474,519 个可能的唯一文件名。我怀疑你会用完 =) 使用 mt_rand 函数以获得最佳结果。