Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function AES_Encrypt(ByVal input As String, ByVal pass As String) As String
- Dim AES As New System.Security.Cryptography.RijndaelManaged
- Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim encrypted As String = ""
- Try
- Dim hash(31) As Byte
- Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
- Array.Copy(temp, 0, hash, 0, 16)
- Array.Copy(temp, 0, hash, 15, 16)
- AES.Key = hash
- AES.Mode = Security.Cryptography.CipherMode.ECB
- Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateEncryptor
- Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
- encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Return encrypted
- Catch ex As Exception
- End Try
- End Function
- Private Sub BCreateAcount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BCreateAcount.Click
- Dim conn As MySqlConnection
- conn = New MySqlConnection
- conn.ConnectionString = "server = localhost;username= root;password= a;database= database"
- Try
- conn.Open()
- Catch mali As MySqlException
- MsgBox("connot establish connection")
- End Try
- Dim myCommand As New MySqlCommand
- Dim myReader As MySqlDataReader
- myCommand.Connection = conn
- myCommand.CommandText = "insert into user values('" + txtUserName.Text + "','" + txtNewPassword.Text + "')"
- Call calldaw()
- If txtUserName.Text = "" Or txtNewPassword.Text = "" Or txtConfirmPassword.Text = "" Then
- MsgBox("Please enter username and password", MsgBoxStyle.Information, "Inventory System")
- ElseIf txtConfirmPassword.Text = txtNewPassword.Text Then
- MsgBox("Account Created", MsgBoxStyle.Information, "Inventory System")
- myReader = myCommand.ExecuteReader()
- txtUserName.Text = ""
- txtNewPassword.Text = ""
- txtConfirmPassword.Text = ""
- Else
- MsgBox("Password did not match", MsgBoxStyle.Critical, "Inventory System")
- txtConfirmPassword.Text = ""
- txtNewPassword.Text = ""
- txtUserName.Text = ""
- End If
- End Sub
- Private Sub calldaw()
- Dim conn As MySqlConnection
- conn = New MySqlConnection
- conn.ConnectionString = "server = localhost;username= root;password= a;database= database"
- Try
- conn.Open()
- Catch mali As MySqlException
- MsgBox("connot establish connection")
- End Try
- Dim myData As MySqlDataAdapter
- Dim reason As String = " Create Account "
- Dim tao As String = "admin"
- myData = New MySqlDataAdapter
- Dim sqlsql = "insert into daily_log values('" + tao + "','" + Date1.Text + "','" + reason + "','" + Time1.Text + "')"
- Dim ssql = "Select * from user"
- Dim myCommand As New MySqlCommand
- myCommand.Connection = conn
- myCommand.CommandText = sqlsql
- Dim myReader As MySqlDataReader
- myReader = myCommand.ExecuteReader
- End Sub
- Private Sub BBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BBack.Click
- Me.Close()
- End Sub
- Private Sub user_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Timer1.Enabled = True
- End Sub
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- Date1.Text = Date.Today.Date
- Dim Date2 As Date = Date1.Text
- Date1.Text = Format(Date2, "yyyy-MM-dd")
- Time1.Text = TimeOfDay
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement