Hello, I'm having trouble with a function returning two values. Each value contains a string, how can I return these values and have each one of them be stored in one independent variable.
How can I do this? This is my code:
vb.net Code:
Public Shared Function SHA256StringHash(ByVal text As String, Optional ByVal salt As Boolean = False) As String Try Select Case salt Case True Dim textBytes As Byte() = _encoding.GetBytes(text) Dim myrandom As New Random Dim rng As New RNGCryptoServiceProvider Dim randomSalt As Byte() = New Byte(myrandom.Next(4, 8)) {} rng.GetNonZeroBytes(randomSalt) Dim SaltedText_Byte As Byte() = New Byte((textBytes.Length + randomSalt.Length) - 1) {} SaltedText_Byte = textBytes.Concat(randomSalt).ToArray Dim SaltedHash As Byte() = hash.ComputeHash(SaltedText_Byte) Return Convert.ToBase64String(SaltedHash) _ AndAlso Convert.ToBase64String(randomSalt) Return Nothing Case Else Dim textBytes As Byte() = _encoding.GetBytes(text) Dim textHash As Byte() = hash.ComputeHash(textBytes) Return Convert.ToBase64String(textHash) End Select Catch ex As Exception Return ex.Message End Try End Function
I'm trying to return the hashed text with the salt and the generated salt, how can I do this?
Thanks in advance!





Reply With Quote