Visual basic 6.0 - ComputeHash invalid procedure call or argument error
Posted
by Mohan Babu Vijaya Gopal
on Stack Overflow
See other posts from Stack Overflow
or by Mohan Babu Vijaya Gopal
Published on 2010-02-07T03:35:12Z
Indexed on
2010/06/08
2:02 UTC
Read the original article
Hit count: 501
I am getting the error "invalid procedure call or arguments" at the step computeHash(). Any help highly appreciated.
Private Sub Form_Load()
Dim rngcsp As New RNGCryptoServiceProvider '= new RNGCryptoServiceProvider()
Dim u8 As Encoding
'u8 = Encoding.UTF8
Dim minSaltSize As Integer
Dim maxSaltSize As Integer
Dim saltSize As Integer
minSaltSize = 4
maxSaltSize = 8
Dim randm As Random
Set randm = New Random
Dim saltBytes() As Byte
ReDim saltBytes(saltSize)
Set rngcsp = New RNGCryptoServiceProvider
rngcsp.GetNonZeroBytes (saltBytes)
Dim plainTextBytes() As Byte
plainTextBytes() = ConvertStringToUtf8Bytes("Mohan")
Dim plainTextBytesLen As Long
plainTextBytesLen = UBound(plainTextBytes) - LBound(plainTextBytes) + 1
Dim saltBytesLen As Long
saltBytesLen = UBound(saltBytes) - LBound(saltBytes) + 1
Dim plainTextWithSaltBytes() As Byte
ReDim plainTextWithSaltBytes(plainTextBytesLen + saltBytesLen)
For i = 0 To plainTextBytesLen - 1
plainTextWithSaltBytes(i) = plainTextBytes(i)
Next
For i = 0 To saltBytesLen - 1
plainTextWithSaltBytes(i) = saltBytes(i)
Next
'Dim hash As HashAlgorithm = New MD5CryptoServiceProvider()
Dim hash12 As New SHA256Managed
'SHA256Managed
Dim totLen As Integer
totLen = plainTextBytesLen + saltBytesLen
Dim str As String
Dim hashBytes() As Byte
'With
hashBytes = hash12.computeHash(plainTextWithSaltBytes) ', 0, totLen)
'End With
End Sub
© Stack Overflow or respective owner