dongyouzhui1969 2012-09-16 01:07
浏览 65
已采纳

将随机字符附加到用户上传的照片的末尾

I've seen several sites where the user-contributed image ends off with a string of seemingly random characters.

Example

http://farm2.staticflickr.com/1116/5136519916_f9b8699cdc_o.jpg

Question: Is there a real need to do this if the image filename starts off with the unique id of the photo. This id is taken off the row from the database table corresponding to this image. Following the example above, my guess will be that 5136519916 is the photo's unique id, f9b8699cdc is the random string and o is the size of the image.

  • 写回答

1条回答 默认 最新

  • doutangu4671 2012-09-16 01:19
    关注

    Theoretically, as long as filenames are unique there is no technical reason why you need to add such a randomized string. However, I suspect those strings are there for privacy concerns.

    Imagine if your filenames were simply the photo's unique ID. A bot could systematically scan your entire site getting all the photos simply by incrementing by one. If your users are uploading photos but they don't want everyone to be able to see them (such as with Facebook or private photos in Flickr) then this is a very insecure system. Adding this random string helps hide user's content from unauthorized access by making links harder to guess. This is vaguely addressed by the "How Secure is ImageShack?" question on ImageShack's FAQ.

    The combination of unique identifier + randomized element means both easy calculation of unique IDs (increment the identifier by 1) and easy addition of a random element (generate a string and append it to the ID). Much more efficient than computing a completely random but still unique identifier.

    Technically, a fully random filename would be more secure but even the addition of only three alphanumeric characters (a-zA-Z0-9), a la ImageShack, means that for each unique photo ID the filename could be one of any 52*52*52 = 238382 possibly filenames. All of a sudden, anyone scanning your site to find user's photos isn't having much luck.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算