在url中隐藏真正的数据库对象ID

编程入门 行业动态 更新时间:2024-10-14 22:21:52
本文介绍了在url中隐藏真正的数据库对象ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

出于安全目的,在URL中隐藏真正的数据库对象ID有用的解决方案是什么?我发现其中一个解决方案是:

1)使用

人们应该做些什么改变

解释

通常, >短的随机浏览网址。这不会让您有足够的空间来加密然后进行身份验证您希望混淆的数据库记录ID。这样做需要最少的URL长度为32字节(对于HMAC-SHA256),在base64编码时为44个字符。

一个更简单的策略是生成一个随机字符串(请参阅 random_compat ,了解 random_bytes()和 random_int()来生成这些字符串)并引用该列。 href =carnage.github.io/2015/08/cryptanalysis-of-hashids =nofollow noreferrer> hashids破解通过简单的密码分析。他们的结论是:

我描述的攻击明显优于暴力攻击,因此从加密的角度来看,算法被考虑被打破,回收盐很容易;使攻击者可以在任一方向运行编码,并使属性2无效,以获得理想的散列函数。

不要依赖就可以了。

What would be useful solutions for hiding true database object ID in URL for security purposes? I found that one of the solutions would be:

1) Using hashids open source project

2) Using something like same old md5 on creation of the object to generate hash and store it in database, then use it in url's and querying by them, but the drawback is that querying by auto-incremented primary keys (IDs) is faster than hashes. So I believe the possibility to hash/unhash would be better?

Also as I'm on Symfony, are there maybe bundles that I could not find or built in functionalities that would help?

Please tell me what you found useful based on your experiences.

解决方案

This question has been asked a lot, with different word choice (which makes it difficult to say, "Just search for it!"). This fact prompted a blog post titled, The Comprehensive Guide to URL Parameter Encryption in PHP .

What People Want To Do Here

What People Should Do Instead

Explanation

Typically, people want short random-looking URLs. This doesn't allow you much room to encrypt then authenticate the database record ID you wish to obfuscate. Doing so would require a minimum URL length of 32 bytes (for HMAC-SHA256), which is 44 characters when encoded in base64.

A simpler strategy is to generate a random string (see random_compat for a PHP5 implementation of random_bytes() and random_int() for generating these strings) and reference that column instead.

Also, hashids are broken by simple cryptanalysis. Their conclusion states:

The attack I have described is significantly better than a brute force attack, so from a cryptographic stand point the algorithm is considered to be broken, it is quite easy to recover the salt; making it possible for an attacker to run the encoding in either direction and invalidates property 2 for an ideal hash function.

Don't rely on it.

更多推荐

在url中隐藏真正的数据库对象ID

本文发布于:2023-11-02 03:59:07,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对象   数据库   url   ID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!