MD5 problem in vb 2010
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
You can't have a variable called default because that is a reserved keyword.
Also I can't see what your md5string function is referencing to.
This should probably do what you want:
Also I can't see what your md5string function is referencing to.
This should probably do what you want:
Code: Select all
Dim myMD5 As System.Security.Cryptography.MD5 = System.Security.Cryptography.MD5.Create()
Dim data As Byte() = Encoding.ASCII.GetBytes("to protect")
Dim hash As Byte() = myMD5.ComputeHash(data)
For i As Integer = 0 To hash.Length - 1
MsgBox("hash: byte " & i & " = " & hash(i))
Next
Looks like various syntax errors to me.
When you declare variables you should start with the Dim keyword.
As said before 'default' can't be used for a variable name.
You can't assign the statement 1 To 19 as a variable directly
And your md5string function is yet to be seen
When you declare variables you should start with the Dim keyword.
As said before 'default' can't be used for a variable name.
You can't assign the statement 1 To 19 as a variable directly
And your md5string function is yet to be seen
I have changed to code, So it's only have now 2 errors:
![Image]()
Mirror:
http://img688.imageshack.us/img688/93/2errors.png

Mirror:
http://img688.imageshack.us/img688/93/2errors.png
Yes you're right. I have not no more (syntax) errors, But if I debug, then it gives the follow error:
![Image]()
Here is the whole code

Here is the whole code
Public Class Form1
Dim S(0 To 19)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str1, str2, temp, temp1, temp2, temp3, temp4, temp5, temp6, L As String
Dim i
str2 = "GeenIDCreations"
str1 = "31330172046F07770A760D65106F1365166519301C2E1F2E22680265036F057306660874096D0B760C690E640F6F1163126E14761572177418721A321B301D381E31203221312336243030"
For i = 1 To Len(str1) / 2
temp = Mid(str1, (2 * i - 1), 2)
temp1 = temp1 & Chr("&H" & temp)
Next i
'-----------------------------------------------------------'
temp2 = ""
Dim var
var = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
L = Len(var)
For i = 1 To 19
S(i) = Mid(var, Rnd() * (L - 1) + 1, 1)
temp2 = temp2 & S(i)
Next i
'-----------------------------------------------------------'
Dim myMD5 As System.Security.Cryptography.MD5 = System.Security.Cryptography.MD5.Create()
Dim data As Byte() = Encoding.ASCII.GetBytes("to protect")
Dim hash As Byte() = myMD5.ComputeHash(data)
temp3 = Mid(temp2, 1, 4) & Mid(temp2, 5, 4) & Mid(temp2, 9, 4) & Mid(temp2, 13, 16)
temp4 = myMD5.Hash(temp1 & temp3 & str2)
temp6 = ""
For i = 1 To Len(temp4) / 2
temp5 = Mid(temp4, 2 * L - 1, 1)
temp6 = temp6 & temp5
Next i
TextBox1.Text = temp3 & Mid(temp6, 1, 4) & Mid(temp6, 5, 4) & Mid(temp6, 9, 4) & str2
MD5.Hash is a property (of the byte array type) that would equal the same result from the ComputeHash function in this case.
You are getting that exception because you are telling VB to return a value out of this array at an invalid index.
You are getting that exception because you are telling VB to return a value out of this array at an invalid index.
Ok, but my english is not very good, and my visual basic knowledge also, so I don't now to change the code correctly.
Mayby you can?
Mayby you can?
Copyright Information
Copyright © Codenstuff.com 2020 - 2023