为加密数据创建订单列 [英] Creating an Order Column for encrypted data

查看:145
本文介绍了为加密数据创建订单列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将加密数据保存到数据库。

I am saving encrypted data to a database.

有没有办法我可以创建一个哈希码或指纹或者纯文本数据的校验和,我通过哈希码排序/排序顺序将与保存纯文本数据并按其操作执行相同的排序/顺序相同?

Is there a way I can create a "hashcode" or fingerprint or checksum of the plain text data, that if I sort / order by on the "hashcode" the order would be the same as if I had saved the plain text data and perform the same sort / order by operation on it?

我基本上需要一个SOUNDEX()类型的函数,它将给我一个保持纯文本数据顺序的值。然后,我将保存加密数据和哈希码,当通过哈希码字段查询数据顺序时。

I basically need a SOUNDEX() type function that will give me a value that will maintain the order of the plain text data. I would then save both encrypted data and the "hashcode" and when querying the data order by the "hashcode" field.

我需要在应用程序中执行此操作不是在SQL数据库中,如果可能的话。

I need to perform this in the application and preferably not in the SQL DB if at all possible.

我正在使用Entity Framework和SQL 2008和C#4.0。

I am using Entity Framework and SQL 2008 and C# 4.0.

推荐答案

加密有意破坏明文中的任何明显的结构,所以任何排序结构也将被破坏。考虑到未加密记录的已知结构,使用非加密哈希码将导致潜在的安全漏洞。

Encrypting intentionally destroys any apparent structure in the plaintext, so any ordering structure will also be destroyed. Using a non-cryptographic hashcode will cause a potential security leak, given the known structure of the unencrypted records.

您可以轻松地从未加密的数据和存储中创建订单列但是,每次添加新记录时,都需要解密数据库的全部或部分。

You could easily create an order column from the unencrypted data and store that, but it would require decrypting all or part of the database every time a new record was added.

您可以先按每10:10,20, 30,...这将允许使用二进制搜索插入新记录。经常解密和重新编号整个数据库,恢复记录之间的差距。不是一个理想的解决方案,但可能是一个。

You could start by numbering the records every ten: 10, 20, 30, ... which would allow the insertion of new records using binary search. Every so often decrypt and renumber the entire database, restoring the gaps between records. Not an ideal solution, but a possible one.

这篇关于为加密数据创建订单列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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