如何创建加密算法加密密钥?密钥、加密算法

由网友(xtreme゜虐爱)分享简介:我想使用的加密算法在.NET安全命名空间中可用,但是我想了解如何生成密钥,例如AES算法需要256位,即16个字节的关键,而一些初始化向量,这也是几字节。 I want to use encryption algorithm available in .Net Security namespace, however...

我想使用的加密算法在.NET安全命名空间中可用,但是我想了解如何生成密钥,例如AES算法需要256位,即16个字节的关键,而一些初始化向量,这也是几字节。

I want to use encryption algorithm available in .Net Security namespace, however I am trying to understand how to generate the key, for example AES algorithm needs 256 bits, that 16 bytes key, and some initialization vector, which is also few bytes.

我可以使用值的任意组合,在我的密钥和IV?例如在关键的第四和全部为零的有效还是无效?我知道算法做大量的异或的细节,所以零不会有什么好处,但是否有任何限制这些算法?

Can I use any combination of values in my Key and IV? e.g. all zeros in Key and IV are valid or not? I know the detail of algorithm which does lots of xors, so zero wont serve any good, but are there any restrictions by these algorithms?

或我使用一些程序来生成密钥,并永久保存的地方?

Or Do I have to generate the key using some program and save it permanently somewhere?

欲加密后在数据库中存储的数据,如用户名,密码,电话号码等,以及该密钥的安全描述文件数据将提供给仅在连接串中提到的数据库用户,并给管理员。

I want to store data in database after encryption, the secure profile data like username, password, phone number etc, and the key will be available to database user mentioned in connection string only, and to the administrator.

推荐答案

如果您正在使用加密来交换数据,那么你将需要一个密钥交换协议,但你不要做一个自己,而不是使用一个现成的,货架像TLS或SSL。

If you are using encryption to exchange data then you will need a key exchange protocol, but you don't make one yourself instead use one off-the-shelf like TLS or SSL.

如果您使用加密来存储数据,然后生成使用四 CryptGenRandom (或其等值.NET RandomNumberGenerator.GetBytes)并将其保存在文档(以清晰,无需要保护IV)你从来不写下来的关键,关键是由用户提供Usualy您源于一个密码短语使用的

阅读全文

相关推荐

最新文章