In my web application, before insert password in db, I create a random salt, and later I pass this salt to an hash function, like this:
salt: e02017446d08af19925df8836c49a0626f65718ace542db7c5593de7a3c34024
hash: d2f36c5a8e86d7893b8a4e16028ec0fd95748e18b9625087acc61545f6cb1df8
This is my vb.net function:
salt: Y&1oY)g)u}2P%RD%Z+ou1d1LTnc<Ik#6bgR9r]6E$]{{4<6^4x)0DG^]PpV$qh!KN]&h<WXePk96f2jT8oWnsL3UsWtB1+pgM&$8
hash: oh6wErU5dPdgXugmQcGX8Mt1pXomImpKxJvePCvr9k9L5bXQiyod3kLUNnzmJ6O4lRHivIoWQXNKSSbRQQhSGQ==
Now my problem's that when I create a new user or update a password for a specific user from my vb.net app, the web application can't execute the login to my user, maybe the password encoding is diffent, so I need a function for vb.net or php that allow me to have the same encoding. How I can do that?
Code:
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;
}
hash: d2f36c5a8e86d7893b8a4e16028ec0fd95748e18b9625087acc61545f6cb1df8
This is my vb.net function:
Code:
Public Shared Function CreateRandomSalt() As String
Dim mix As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+=][}{<>"
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
hash: oh6wErU5dPdgXugmQcGX8Mt1pXomImpKxJvePCvr9k9L5bXQiyod3kLUNnzmJ6O4lRHivIoWQXNKSSbRQQhSGQ==
Now my problem's that when I create a new user or update a password for a specific user from my vb.net app, the web application can't execute the login to my user, maybe the password encoding is diffent, so I need a function for vb.net or php that allow me to have the same encoding. How I can do that?