[英]How to create a unique key from an ID
I am currently working on a text sharing website and I came across the following problem. 我目前在一个文本共享网站上工作,遇到了以下问题。 Each post gets an ID and I would like to be able to easily access the post this by giving the id in the link as a parameter.
每个帖子都有一个ID,我希望能够通过在链接中提供ID作为参数来轻松访问此帖子。 But since you can simply enter the numbers manually, it is very insecure.
但是由于您可以简单地手动输入数字,因此非常不安全。 My idea is to calculate a longer unique number from the ID.
我的想法是根据ID计算更长的唯一编号。 Of course, the number needs to be brought into its original state.
当然,该数字需要恢复到原始状态。 The ideal would be a solution in a python.
理想的解决方案是使用python解决方案。 Thanks in advance!
提前致谢!
Edit: Correct me if I am wrong but there is no way to reverse the uuid back to the original number? 编辑:如果我错了,请纠正我,但是没有办法将uuid还原回原始数字吗?
First thing that needs to be said is that it's not insecure. 首先要说的是它不是不安全的。 Even if you calculate some longer number, there is still a chance to access it anyway.
即使您计算出更长的数字,仍然仍然有机会访问它。 Imagine someone creating a generator script trying such numbers.
想象一下有人创建了一个生成器脚本来尝试这些数字。 Giving post an ID and security shouldn't be mixed up together.
提供ID和安全性不应混为一谈。
The best solution would be to add some kind of privileges system or password protection. 最好的解决方案是添加某种特权系统或密码保护。 You can of course use some hash functions for making the id longer if you insist.
如果您坚持,当然可以使用一些哈希函数来使ID更长。 Not sure what exactly is the idea behind the website, you mean something like Pastebin ?
不确定网站背后的想法到底是什么,您是说类似Pastebin吗? Simply add an option for the password protection as I suggested before.
就像我之前建议的那样,只需添加一个密码保护选项。 Some might use it, some don't.
有些人可能会使用它,有些人不会。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.