vb.net - mysql 最新的密码哈希算法/数据加密是什么?

标签 vb.net visual-studio security

由于我对密码学知之甚少,我试图找到在某些 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 毫秒,然后将盐与哈希一起保存。使用诸如 ehashPBKDF2Bcryptpasslib.hash 等函数或类似函数。重点是让攻击者花费大量时间通过暴力破解来查找密码。

NIST目前推荐PBKDF2用于密码验证器。

参见:

关于vb.net - mysql 最新的密码哈希算法/数据加密是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45340323/

相关文章:

android - 包权限的含义(邀请所有android开发者贡献)

android - android中的debug.keystore有什么用?

.net - 在多线程中使用 GDI+ 的问题 (VB.NET)

c# - 可序列化继承

javascript - 级联下拉菜单干扰自动完成文本框

.net - 引用两个相等的程序集,只有公钥不同

c# - Cecil - 获取定义的属性属性

multithreading - 单元测试时如何处理其他线程中引发的异常?

visual-studio - 为什么我的 Release 目录中有一个 pdb 文件?

asp.net-mvc - ReturnUrl 指向 ActionResult