duandong1869 2010-02-19 22:21
浏览 526

加密/解密主键而不是使用UID?

Although I always check that someone is allowed to access a record, I normally use a UID in query strings as I feel it discourages the temptation to "poke around" that ?id=1, ?id=2 does.

I find though that it makes it a bit convoluted to do lookups across multiple tables as you need to store the UID as well instead of just the record id.

If I was to pass an encrypted string of the id number through the query string and then decrypt it to do a database query would this add massive overhead?

This would mean I can just work with the primary key (though I would still obviously check that they have permission to view the record) and could make unique links each session (or change anytime throughout a session) - which would be useful if there's a lot of AJAX driven content you don't want them trying to play with.

Is this a really bad idea?

  • 写回答

4条回答 默认 最新

  • douqianbiao4216 2010-02-19 22:27
    关注

    Why not just base64encode/decode the IDs? If you're only doing this to prevent legitimate users from experimenting with toys they do in fact have permission to play with anyhow, there is really no purpose in doing anything particularly fancy to discourage them.

    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?