Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. Public Function AES_Encrypt(ByVal input As String, ByVal pass As String) As String
  2. Dim AES As New System.Security.Cryptography.RijndaelManaged
  3. Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
  4. Dim encrypted As String = ""
  5. Try
  6. Dim hash(31) As Byte
  7. Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
  8. Array.Copy(temp, 0, hash, 0, 16)
  9. Array.Copy(temp, 0, hash, 15, 16)
  10. AES.Key = hash
  11. AES.Mode = Security.Cryptography.CipherMode.ECB
  12. Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateEncryptor
  13. Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
  14. encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
  15. Return encrypted
  16.  
  17. Catch ex As Exception
  18.  
  19. End Try
  20. End Function
  21.  
  22. Private Sub BCreateAcount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BCreateAcount.Click
  23. Dim conn As MySqlConnection
  24. conn = New MySqlConnection
  25.  
  26. conn.ConnectionString = "server = localhost;username= root;password= a;database= database"
  27.  
  28. Try
  29. conn.Open()
  30. Catch mali As MySqlException
  31. MsgBox("connot establish connection")
  32. End Try
  33. Dim myCommand As New MySqlCommand
  34. Dim myReader As MySqlDataReader
  35.  
  36.  
  37. myCommand.Connection = conn
  38. myCommand.CommandText = "insert into user values('" + txtUserName.Text + "','" + txtNewPassword.Text + "')"
  39. Call calldaw()
  40.  
  41.  
  42. If txtUserName.Text = "" Or txtNewPassword.Text = "" Or txtConfirmPassword.Text = "" Then
  43. MsgBox("Please enter username and password", MsgBoxStyle.Information, "Inventory System")
  44. ElseIf txtConfirmPassword.Text = txtNewPassword.Text Then
  45.  
  46. MsgBox("Account Created", MsgBoxStyle.Information, "Inventory System")
  47. myReader = myCommand.ExecuteReader()
  48. txtUserName.Text = ""
  49. txtNewPassword.Text = ""
  50. txtConfirmPassword.Text = ""
  51.  
  52. Else
  53. MsgBox("Password did not match", MsgBoxStyle.Critical, "Inventory System")
  54. txtConfirmPassword.Text = ""
  55. txtNewPassword.Text = ""
  56. txtUserName.Text = ""
  57. End If
  58.  
  59. End Sub
  60. Private Sub calldaw()
  61. Dim conn As MySqlConnection
  62. conn = New MySqlConnection
  63.  
  64. conn.ConnectionString = "server = localhost;username= root;password= a;database= database"
  65.  
  66. Try
  67. conn.Open()
  68. Catch mali As MySqlException
  69. MsgBox("connot establish connection")
  70. End Try
  71.  
  72. Dim myData As MySqlDataAdapter
  73. Dim reason As String = " Create Account "
  74. Dim tao As String = "admin"
  75.  
  76. myData = New MySqlDataAdapter
  77.  
  78. Dim sqlsql = "insert into daily_log values('" + tao + "','" + Date1.Text + "','" + reason + "','" + Time1.Text + "')"
  79. Dim ssql = "Select * from user"
  80.  
  81. Dim myCommand As New MySqlCommand
  82. myCommand.Connection = conn
  83. myCommand.CommandText = sqlsql
  84.  
  85. Dim myReader As MySqlDataReader
  86. myReader = myCommand.ExecuteReader
  87.  
  88. End Sub
  89.  
  90. Private Sub BBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BBack.Click
  91. Me.Close()
  92. End Sub
  93.  
  94. Private Sub user_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  95. Timer1.Enabled = True
  96. End Sub
  97.  
  98. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  99. Date1.Text = Date.Today.Date
  100. Dim Date2 As Date = Date1.Text
  101. Date1.Text = Format(Date2, "yyyy-MM-dd")
  102. Time1.Text = TimeOfDay
  103. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement