如何加密字符串,并获得相等的长度加密的字符串?字符串、长度

由网友(清川带长薄)分享简介:我的问题是这样的:在我想在一列中的数据进行加密现有数据库。列包含不同长度的串In an existing database I want to encrypt data in a couple of columns.The columns contains strings of different length...

我的问题是这样的:

在我想在一列中的数据进行加密现有数据库。 列包含不同长度的串

In an existing database I want to encrypt data in a couple of columns. The columns contains strings of different lengths.

我不想更改列的大小,以便加密需要产生输入文本的长度相等的文本再presentation。

I don't want to change the size of the columns so the encryption need to produce an equal length text representation of the input text.

加密算法的强度是次要的兴趣,但我当然希望它是强,因为它可以。否则,我不需要对数据进行加密。但最重要的是输出的大小。

The strength of the encryption algorithm is of secondary interest but of course I want it to be as strong as it can be. Otherwise I wouldn't need to encrypt the data. But the most important thing is the size of the output.

这可能吗? 如果是的话我会怎么做呢?

Is this possible? If so how would I do it?

我有兴趣做的.NET。没有数据库级加密。

I'm interested in doing it in .NET. No database-level encryption.

推荐答案

在你的constrants,我会用AES中的 CFB 的模式,从而把它变成一个流密码和输出长度将是相同的作为输入的长度。除非你存储在斑点的字符串,则需要十六进制或Base64 EN code的输出,使其烧焦友好的,这将是在长度上增加了100%或33%。

Within your constrants, I would use AES in CFB mode, which turns it into a stream cipher and the output length will be the same as the input length. Unless you're storing the strings in blobs, you'll need to hex or base64 encode the output to make it char friendly, which will be a 100% or 33% increase in length.

一个.NET实现是这里。

阅读全文

相关推荐

最新文章