开发者

Is there an encryption method for a column with a data type of int?

开发者 https://www.devze.com 2022-12-24 01:18 出处:网络
The scenario is that I want to encrypt finance numbers in a column with a data type of int in a sql server table.

The scenario is that I want to encrypt finance numbers in a column with a data type of int in a sql server table. It is a big app so it is difficult to change the table column data type from int to any other data type.

I'm using sql server 2005 and asp开发者_C百科.net C#.

Is there a two-way encryption method for a column with a data type of int?

Could I use a user-defined-function in sql server 2005 or a possibly a C# method?


I'm sorry but I simply can't see the rationale for encrypting numbers in a database. If you want to protect the data from prying eyes, surely SQL Server has security built into it, yes?

In that case, protect the database with its standard security. If not, get a better DBMS (though I'd be surprised if this were necessary).

If you have bits of information from that table that you want to make available (like some columns but not others), use a view, or a trigger to update another table (less secured), or a periodic transfer to that table.


XOR?

:)

Hmm, need more text...

 


There are a few two way encryption schemes available in .Net.

Simple insecure two-way "obfuscation" for C#

You can either convert the integer to it's byte array equivalent or convert it to a base-64 string and encrypt that.


Well, every injective, surjective function from int to int can be used as a way to "encode" an integer.

You could build such a function by creating a random array with 65536 items with no duplicate entries und using f(i) = a[i]. To "decode" your int you simply create another array with b[i] = x | a[x] = i.

As the others have mentioned, this may not be what you REALLY want to do. =)

Edit: Check out Jim Dennis' comment!


You might want to look at format preserving encryption.

0

精彩评论

暂无评论...
验证码 换一张
取 消