雖然我並不熟悉鹽應該如何工作,但我創建了一個函數,其中包含密碼和鹽,然後將它們用作輸入來創建最終的哈希。
你需要這些:
Imports System.Security.Cryptography
Imports System.Text
Imports System.IO
要運行此:
Private Function CreateMD5(password As String, salt As String) As String
Dim passwordBytes() As Byte = Encoding.UTF8.GetBytes(password)
Dim saltBytes() As Byte = Encoding.UTF8.GetBytes(salt)
Dim saltedPasswordHash As Byte()
Dim md5Hasher As MD5 = Security.Cryptography.MD5.Create()
Dim buffer As New MemoryStream
Dim writer As New StreamWriter(buffer) With {.AutoFlush = True}
Try
writer.Write(md5Hasher.ComputeHash(passwordBytes))
writer.Write(md5Hasher.ComputeHash(saltBytes))
buffer.Position = 0
saltedPasswordHash = md5Hasher.ComputeHash(buffer)
Finally
writer.Dispose()
buffer.Dispose()
md5Hasher.Dispose()
End Try
Return String.Concat(BitConverter.ToString(saltedPasswordHash).Split("-"c))
End Function
用法示例:
Dim saltedHash As String = CreateMD5("password", "salt")
Console.WriteLine(saltedHash)
輸出:
CDA7359AB6408E7F0088CAB68470D5FE
從哪裏得到鹽?它是存儲在數據庫字段中的隨機鹽 – Orangepill
使用[本指南]可能需要爲ipboard實施您自己的登錄適配器(http://www.invisionpower.com/support/guides/_/advanced-and-developers/整合/登錄模塊-R42) – Orangepill