由于我对密码学知之甚少,我试图找到在某些 vb.net winform
应用程序中对用户密码进行哈希处理的最佳方法;然后将其存储在在线mysql
数据库中。
我发现了很多关于该主题的帖子,但无法找出哪一个是最好的方法。
我到达this MSDN post但仍然不确定是否可以使用它。
我无法在哪里输入一些随 secret 钥,它是由函数自动生成的。
所以我的问题是,这是一个可靠的密码哈希函数吗? 还有其他选择吗?
谢谢
代码:
Imports System Imports System.IO Imports System.Security.Cryptography Class AesExample Public Shared Sub Main() Try Dim original As String = "Here is some data to encrypt!" ' Create a new instance of the Aes ' class. This generates a new key and initialization ' vector (IV). Using myAes As Aes = Aes.Create() ' Encrypt the string to an array of bytes. Dim encrypted As Byte() = EncryptStringToBytes_Aes(original, myAes.Key, myAes.IV) ' Decrypt the bytes to a string. Dim roundtrip As String = DecryptStringFromBytes_Aes(encrypted, myAes.Key, myAes.IV) 'Display the original data and the decrypted data. Console.WriteLine("Original: {0}", original) Console.WriteLine("Round Trip: {0}", roundtrip) End Using Catch e As Exception Console.WriteLine("Error: {0}", e.Message) End Try End Sub 'Main Shared Function EncryptStringToBytes_Aes(ByVal plainText As String, ByVal Key() As Byte, ByVal IV() As Byte) As Byte() ' Check arguments. If plainText Is Nothing OrElse plainText.Length
最佳答案
不要加密密码,当攻击者获得数据库时,他也将获得加密 key 。仅使用哈希函数是不够的,仅添加盐对于提高安全性几乎没有作用。使用随机盐迭代 HMAC 约 100 毫秒,然后将盐与哈希一起保存。使用诸如 ehash
、PBKDF2
、Bcrypt
、passlib.hash
等函数或类似函数。重点是让攻击者花费大量时间通过暴力破解来查找密码。
参见:
NIST 特别出版物 800-63B:( Digital Identity Guidelines )
关于vb.net - mysql 最新的密码哈希算法/数据加密是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45340323/