Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim DES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
- Dim Hash As New System.Security.Cryptography.MD5CryptoServiceProvider
- Try
- DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(My.Settings.Key))
- DES.Mode = System.Security.Cryptography.CipherMode.ECB
- Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateDecryptor
- Dim Buffer As Byte() = Convert.FromBase64String(TextBoxCard.Text)
- TextBoxCard.Text = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Catch ex As Exception
- MessageBox.Show("The following error(s) have occurred: " & ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
- End Try
- Private Sub loadRecords()
- 'FOR MySQL DATABASE USE
- Dim dbConn As New MySqlConnection
- Dim dbTable As New DataTable
- Dim dbQuery As String = ""
- Dim dbCmd As New MySqlCommand
- Dim dbAdapter As New MySqlDataAdapter
- dbTable.Clear()
- Try
- If dbConn.State = ConnectionState.Closed Then
- dbConn.ConnectionString = String.Format("Server={0};Port={1};Uid={2};Password={3};Database=accounting", FormLogin.ComboBoxServerIP.SelectedItem, My.Settings.DB_Port, My.Settings.DB_UserID, My.Settings.DB_Password)
- dbConn.Open()
- End If
- dbQuery = "SELECT *" & _
- "FROM cc_master INNER JOIN customer ON customer.accountNumber = cc_master.customer_accountNumber " & _
- "ORDER BY nameCOMPANY ASC"
- With dbCmd
- .CommandText = dbQuery
- .Connection = dbConn
- End With
- With dbAdapter
- .SelectCommand = dbCmd
- .Fill(dbTable)
- End With
- ListViewRecords.Items.Clear()
- For i = 0 To dbTable.Rows.Count - 1
- With ListViewRecords
- .Items.Add(dbTable.Rows(i)("ccID"))
- With .Items(.Items.Count - 1).SubItems
- .Add(dbTable.Rows(i)("nameCOMPANY"))
- .Add(dbTable.Rows(i)("ccNumber"))
- .Add(dbTable.Rows(i)("ccExpireMonth"))
- .Add(dbTable.Rows(i)("ccExpireYear"))
- .Add(dbTable.Rows(i)("ccType"))
- .Add(dbTable.Rows(i)("ccAuthorizedUseStart"))
- .Add(dbTable.Rows(i)("ccAuthorizedUseEnd"))
- .Add(dbTable.Rows(i)("ccLocation"))
- .Add(dbTable.Rows(i)("cardholderSalutation"))
- .Add(dbTable.Rows(i)("cardholderLastname"))
- .Add(dbTable.Rows(i)("cardholderFirstname"))
- .Add(dbTable.Rows(i)("ccZipcode"))
- End With
- End With
- Next
- Catch ex As MySqlException
- MessageBox.Show("A DATABASE ERROR HAS OCCURED" & vbCrLf & vbCrLf & ex.Message & vbCrLf & _
- vbCrLf + "Please report this to the IT/Systems Helpdesk at Ext 131.")
- End Try
- dbConn.Close()
- End Sub
- Function Decrypt(ByVal ToDecrypt) as String
- Dim DES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
- Dim Hash As New System.Security.Cryptography.MD5CryptoServiceProvider
- Try
- DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(My.Settings.Key))
- DES.Mode = System.Security.Cryptography.CipherMode.ECB
- Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateDecryptor
- Dim Buffer As Byte() = Convert.FromBase64String(ToDecrypt)
- return System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Catch ex As Exception
- return "Whatever failed message you want"
- End Try
- End Function
- for i as Integer = 0 to dbTable.Rows.Count - 1
- dbTable.Rows(i)("ccNumber")) = Decrypt(dbTable.Rows(i)("ccNumber"))
Add Comment
Please, Sign In to add comment