doutingyou2198 2012-08-08 12:59
浏览 505

生成随机的一次性URL

I'm creating a pretty simple application which allows references (of potential employees) to upload their own reference letters. Here's how it works:

  • The applicant submits the references email
  • The reference receives an automatically generated email containing a unique URL (for security reasons)
  • Reference follows the link, answers security question (in case he wishes to access the site more than once)
  • Uploads letter

I'm stuck on how to generate a completely (okay, okay, quasi will do) random URL. What's more: how do I ensure that following the link will direct the references to the correct page? Do I have to create a new page containing the drop box every time I send out a random URL?

Thanks for any suggestions on how to go about this :)

  • 写回答

4条回答 默认 最新

  • duanguan3863 2012-08-08 13:06
    关注

    You might try using a hash algorithm which generates the unique-esque checksum from the contents of the file. Usually (for example with md5()) one byte change in the original content results in a completely different hash. (Notice: md5 has some collision vulnerabilities.)

    If you store the uploaded file with the filename of the hash, you will be able to retrieve it at a later date, but for more complex system, there should be a database set up which makes the relation between the random URL and the stored content.

    If you don't want to hash, there code snippet below could help to generate random URLs (but make sure that if an URL is already used, you prevent accidental overwrites):

    md5( sha1( time() + rand(0, time()) ) );
    
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料