doulou9927 2016-11-16 15:56
浏览 51
已采纳

使用md5版本的id查询字段

EDITED TO ADD MORE INFO

I need to use mysql's md5 function to select an item using it's id field (uid). I have a separate database from my users called recover_db that has an md5 hashed value of the user id in it and a time stamp.

Currently the users visit a link like this:

recover-MD%HASHEDUSERID.html

Then the system takes that MD%HASHEDUSERID from the url and checks if it exists in the recover_db and if it does it lets them recover the account. There's some other stuff for security and whatnot but I do not store the user id in the recover_db, just the MD5 value of it. I use the following to do that:

md5(90*13/12*56+$id)

Now I need to check the users database and get the REAL account id using the md5 value I have saved. I was using the following query to do this:

$query = "SELECT uid FROM users where md5(90*13/12*56+uid)='".$md5accID."'";

Unfortunately this is returning no results. Is there any way to get the real user id from the users database using the md5 version of it from the recover_db? I want to avoid storing the user id in the recover_db if I can.

  • 写回答

1条回答 默认 最新

  • dro80463 2016-11-16 16:02
    关注

    Save the original user ID in a field origuid together with the hash (hasheduid) in the recovery database. Then do

    $query = "SELECT origuid FROM users where hasheduid='".$md5accID."'";
    

    to retrieve the original user ID.

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

报告相同问题?

悬赏问题

  • ¥15 问题重发,R语言:代码运行过程中出现如下警告,请求如何解决!
  • ¥15 神经网络模型一直不能上GPU
  • ¥15 苍穹外卖拦截器token为null
  • ¥15 pyqt怎么把滑块和输入框相互绑定,求解决!
  • ¥20 wpf datagrid单元闪烁效果失灵
  • ¥15 券商软件上市公司信息获取问题
  • ¥100 ensp启动设备蓝屏,代码clock_watchdog_timeout
  • ¥15 Android studio AVD启动不了
  • ¥15 陆空双模式无人机怎么做
  • ¥15 想咨询点问题,与算法转换,负荷预测,数字孪生有关