douyi5961 2011-03-07 21:32
浏览 54
已采纳

使用PHP散列UID的正确方法

I realize this may be a reproduce of a question from '09 OLD LINK but wanted to see if there was a better way to do now:

ultimately I have the following URL:

www.site.com?ID=12345 (my id's are much more complicated than this).

That being said, it is theoretically possible for somebody to simply change the URl and access other person's data (yes I can also run authentication of ownership on the other side as well).

Ultimately, I want to hash the initial data, put it as the ID value - then on the server processing script (page that is linked to), reverse the hash and use the UID from that member.

  • 写回答

2条回答 默认 最新

  • dqqvravff05370501 2011-03-07 21:36
    关注

    Two choices - use PHP's encryption/decrypt facilities to hide the actual UID. Or store a hashed version of the UID in the database alongside the normal UID.

    You could run a query like

    SELECT blah,blah
    FROM table
    WHERE MD5(id) = 'the query string value'
    

    but that wouldn't allow for indexes to be used, so it'd be better to do

    ...
    WHERE hashed_id = 'the query string value'
    

    instead.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳