Advertisement
Guest User

Untitled

a guest
Jun 4th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.04 KB | None | 0 0
  1. Imports System.Security.Cryptography
  2.  
  3. Imports System.Text
  4.  
  5.  
  6.  
  7. Public Class Form1
  8.  
  9.     Dim password As String = "b521cdb4ba5a2e51d9068914f050486c" ' md5 of "xdemo"
  10.  
  11.     Dim username As String = "bc7dc0884bd2ed66dc4197c686c1a400" 'md5 of "md5login"
  12.  
  13.  
  14.  
  15.  
  16.  
  17.     Function MD5Hash(ByVal strToHash As String) As String
  18.  
  19.         Dim md5Obj As New Security.Cryptography.MD5CryptoServiceProvider
  20.  
  21.         Dim bytes() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)
  22.  
  23.         bytes = md5Obj.ComputeHash(bytes)
  24.  
  25.         Dim strResult As String = ""
  26.  
  27.         For Each b As Byte In bytes
  28.  
  29.             strResult += b.ToString("x2")
  30.  
  31.         Next
  32.  
  33.         Return strResult
  34.  
  35.     End Function
  36.  
  37.  
  38.  
  39.     Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  40.  
  41.     Handles btnLogin.Click
  42.  
  43.         If username = MD5Hash(txtUser.Text) Then
  44.  
  45.             If password = MD5Hash(txtPass.Text) Then
  46.  
  47.                 MsgBox("logged in")
  48.  
  49.             End If
  50.  
  51.         End If
  52.  
  53.     End Sub
  54.  
  55. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement