I'll be showing you guys how to add an MD5 Encryption into your project so for those people who use this as a password :
if textbox1.text = "password" then
bla bla
people can easily get your password :P
So to start out you put this at the top most of your form ( any )
Imports System.Security.Cryptography
Imports System.IO
Then put this right under your Public Class Form
Public oFile As System.IO.File
Public password As String = "MD5 HASH HERE" 'md5 hash of your password
Public enteredpassword As String
Public s As Stream
Now add this function, right under the above code
Function getMD5Hash(ByVal strToHash As String) As String
Dim md5Obj As New Security.Cryptography.MD5CryptoServiceProvider
Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)
bytesToHash = md5Obj.ComputeHash(bytesToHash)
Dim strResult As String = ""
For Each b As Byte In bytesToHash
strResult += b.ToString("x2")
Next
Return strResult
End Function
Now you need to go on google and search for an MD5 encryptor
get the hash and replace the red with your MD5
So here's how you use it
let's say you have a Textbox and a button
the button check to see if the password is correct in textbox1
this is what you would do
enteredpassword = getMD5Hash(Textbox1.Text)
If enteredpassword = password Then
something happens if the password is correct
Else
Something happen when the password is wrong
End If
Thanks for coming :]
No comments:
Post a Comment