简体   繁体   English

如何从ID创建唯一键

[英]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.

相关问题 如何从 10 个长度的数字/字母医疗 ID 创建一个不可逆的唯一 ID? - How to create a irreversible unique ID from a 10 length number/letter medical ID? 如何从pandas中的列创建唯一ID列表,其中ID列表在Python中被提及为字符串 - How to create a list of unique ID from a column in pandas where lists of ID are mentioned as strings in Python 如何在 Python Class 中创建唯一且增量的 ID - How to create a unique and incremental ID in a Python Class 如何为使用sqlite的行分组创建唯一的ID - How to create a unique ID for a grouping of rows with sqlite 如何在Python中为字典创建唯一键 - How To Create a Unique Key For A Dictionary In Python PySpark:如何从给定的 RDD (id, [strings]) 创建唯一字符串列表的 RDD - PySpark: how to create a RDD of lists of unique strings from a given RDD (id, [strings]) 如何从元组列表创建字典而不覆盖第一个唯一键值? - How to create a dictionary from a list of tuples without overwriting the first unique key value? 如何创建密钥字典:column_name和value:python中来自数据框的列中的唯一值 - How to create a dictionary of key : column_name and value : unique values in column in python from a dataframe 如何从字典列表中查找唯一键值以创建新列表 - How to find unique key value from list of dictionary to create new list 如何从列表中创建多个键,每个键都分配给一个唯一的数组? - How do I create multiple keys from a list with each key assigned to a unique array?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM