Trying to write some code to pass things to a web server in the format that it expects. Essentially we have a salt plus some other stuff that we hash together, and then pass the salt and the hash in a web-safe base 64 string to the server.
So, if the salt is 'foo' and the hash is '1234567890' then what the server wants is Base64String("foo1234567890"). I have the following, with an error at the point where I'm trying to concatenate the salt to the hash:
No joy with CType or a couple of other things that I tried. I'm sure the answer must be simple, but I'm not seeing it right now. Any help will be greatly appreciated!
So, if the salt is 'foo' and the hash is '1234567890' then what the server wants is Base64String("foo1234567890"). I have the following, with an error at the point where I'm trying to concatenate the salt to the hash:
Code:
Function GenerateWebsafeMD5(Salt As String, SourceText As String) As String
Dim byteSourceText() As Byte = Encoding.ASCII.GetBytes(SourceText) ' SourceText is the salt+data all together
Dim byteSaltText() As Byte = Encoding.ASCII.GetBytes(Salt)
Dim MyMD5 As New MD5CryptoServiceProvider()
Dim byteHash() As Byte = MyMD5.ComputeHash(byteSourceText)
Dim byteSaltAndHash() As Byte = byteSaltText.Concat(byteHash) ' error here: Option Strict On disallows implicit conversions from 'System.Collections.Generic.IEnumerable(Of Byte)' to '1-dimensional array of Byte'.
Dim OutString As String = Convert.ToBase64String(byteSaltAndHash)
OutString = OutString.Replace("+", "-").Replace("/", "_")
Return OutString
End Function