0
我在写一个需要64位密钥的加密应用程序。我目前使用下面的代码来自动生成一个密钥。生成密钥
Function GenerateKey() As String
' Create an instance of a symmetric algorithm. The key and the IV are generated automatically.
Dim desCrypto As DESCryptoServiceProvider = DESCryptoServiceProvider.Create()
' Use the automatically generated key for encryption.
Return ASCIIEncoding.ASCII.GetString(desCrypto.Key)
End Function
我想让用户创建自己的密钥。我可以将用户定义的密码(字符串)转换为可以使用的64位密钥吗?
你需要用你的密码加一些盐来生成密钥。盐的随机性和隐私以及散列算法的质量至关重要。 – Jodrell 2012-02-01 09:57:03
然后还有其他构造函数将这些散列字节传入。 – weston 2012-02-01 10:19:44
如果可能,你可以给我一个例子吗? – 2012-02-01 10:23:47