完善哈希函数混淆顺序值 [英] Perfect hash function to obfuscate a sequential value

查看:149
本文介绍了完善哈希函数混淆顺序值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我需要的(语言:C#4):

我建立一个系统,你可以提出申诉。已提交的投诉后,您将得到识别系统投诉独特的9位数字。

有关安全性(安全透过朦胧)的目的,我不想票的ID是连续的。但我的要使用数据库来生成顺序编号。

所以,我需要的是一个射功能是快速两种方式:序列号,我的票号,从票号回序列号

所以,在数据库中我的 ticketId 是连续的,但显示给用户之前,我会混淆这,同样,当我得到了多少回,从用户,我去混淆它,并用它来查找投诉到数据库中。

混淆的部分并不需要太复杂,只是看不出来足够的为普通大众。

例如,我可以简单地改变值的位数,这将让我(8位值):

  

0 - > 0
  1 - > 128
  2 - > 192
  3 - > 64
  4 - > 160
  5 - > 96

     

等。

解决方案

我想你可以解决这个问题很好:加密的票号以恒定的关键。 <一href="http://stackoverflow.com/questions/513056/which-good-block-encryption-algorithm-has-the-shortest-output">There是一个32位的块大小的块加密,您可以使用。

Here is what I need (language: C# 4):

I am building a system where you can submit complaints. After complaint has been submitted you are given a unique 9 digits number that identifies your complaint in the system.

For security (security through obscurity) purposes I do not want ticket IDs to be sequential. But I do want to use database to generate sequential id.

So what I need is a injective function that is fast both ways: sequential number to my ticket id, and back from ticket id to the sequential number.

So that my ticketId in database is sequential, but before showing it to a user I will obfuscate it, similarly, when I get a number back from the user, I de-obfuscate it and use it to look up complaint in the database.

The obfuscation part does not need to be too complicated, just "not apparent enough" for general public.

For example I could simply change bitness of the value, which will get me (for 8-bit values):

0 -> 0
1 -> 128
2 -> 192
3 -> 64
4 -> 160
5 -> 96

etc.

解决方案

I think you can solve this problem perfectly: Encrypt the ticket number with a constant key. There is a 32-bit block-size block cipher that you can use.

这篇关于完善哈希函数混淆顺序值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆