0
在我的web应用程序,我创建一个随机盐,后来我通过这种盐的哈希函数,就像这样:等效密码哈希函数vb.net
function generate_salt()
{
$max_length = 100;
$salt = hash('sha256', (uniqid(rand(), true)));
return substr($salt, 0, $max_length);
}
function hash_password($salt, $password)
{
$half = (int)(strlen($salt)/2);
$hash = hash('sha256', substr($salt, 0, $half) . $password . substr($salt, $half));
for ($i = 0; $i < 100000; $i++)
{
$hash = hash('sha256', $hash);
}
return $hash;
}
这是我vb.net
功能:
Public Shared Function CreateRandomSalt() As String
Dim mix As String = "[email protected]#$%^&*()_+=][}{<>"
Dim salt As String = ""
Dim rnd As New Random
Dim sb As New StringBuilder
For i As Integer = 1 To 100 'Lunghezza del salt
Dim x As Integer = rnd.Next(0, mix.Length - 1)
salt &= (mix.Substring(x, 1))
Next
Return salt
End Function
Public Shared Function Hash512(password As String, salt As String) As String
Dim convertedToBytes As Byte() = Encoding.UTF8.GetBytes(password & salt)
Dim hashType As HashAlgorithm = New SHA512Managed()
Dim hashBytes As Byte() = hashType.ComputeHash(convertedToBytes)
Dim hashedResult As String = Convert.ToBase64String(hashBytes)
Return hashedResult
End Function
现在我的问题是,当我创建一个新用户或从我vb.net
的应用程序更新为特定用户的密码,Web应用程序不能执行登录我的用户,也许密码编码是不同的,所以我需要一个012的功能或php
,让我有相同的编码。我该怎么做?
[A PHP等效为一个VB.NET密码哈希函数(的可能的复制http://stackoverflow.com/questions/ 19457726/a-php-equivalent-for-a-vb-net-password-hash-function) – Plutonix
但是我有一个编码为256的 –
你是否储存盐或每次用户尝试登录时生成一个随机数? –