Hello people. Im having a problem in my coding. I am doing a username and password application (sumtthing like a password keeper). So I have created the interface and i integrated vb 2008 with sql server 2008. So the adding of account and password all went fine. I have applied aes 128 bits for the password. that means when the user enters a new record for example an email and he click save, the password will automatically be encrypted before it is saved in the database. now im having a problem where when i want to display the password in the gridview of vb.net (i decided to use grid view to show all the username and password), i am having trouble in decrypting the password column to show the real password to the user. of course user cant decrypt the password using their brains. so I want to know how to choose dat particular column (password column) and decrypt it before it appears in the gridview. bcoz now it is appearing gibberish i.e. aes 128 bits. Please help me. Below i show u some snippet of my codes in encrypting and storing it in the database.
Private Sub btnemailAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnemailAdd.Click If txtEmailName.Text <> "" And txtEmailDesc.Text <> "" And txtEmailUsrname.Text <> "" And txtEmailPass.Text <> "" Then Dim ciphertext As String ciphertext = Encrypt(txtEmailPass.Text) txtEncrypt.Text = ciphertext 'Dim NetStream As NetworkStream = TCPClient.GetStream() 'Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(Encrypt(txtEmailPass.Text)) 'NetStream.Write(sendBytes, 0, sendBytes.Length) 'Dim sequelAdapterReg As New SqlDataAdapter() sequelDataAdapter.InsertCommand = New SqlCommand("INSERT INTO EMAILinfo VALUES(@EmailName, @EmailDescription, @EmailUsername, @EmailPassword)", sequelConnectionReg) sequelDataAdapter.InsertCommand.Parameters.Add("@EmailName", SqlDbType.VarChar).Value = txtEmailName.Text sequelDataAdapter.InsertCommand.Parameters.Add("@EmailDescription", SqlDbType.VarChar).Value = txtEmailDesc.Text sequelDataAdapter.InsertCommand.Parameters.Add("@EmailUsername", SqlDbType.VarChar).Value = txtEmailUsrname.Text sequelDataAdapter.InsertCommand.Parameters.Add("@EmailPassword", SqlDbType.VarChar).Value = txtEncrypt.Text sequelConnectionReg.Open() sequelDataAdapter.InsertCommand.ExecuteNonQuery() sequelConnectionReg.Close() MsgBox("Email Has Been Successfully Added!", MsgBoxStyle.Information) Me.Close() sequelDataSet.Clear() sequelDataAdapter.Fill(sequelDataSet) InterfaceMain.emailDataGrid.DataSource = sequelDataSet.Tables(0) InterfaceMain.Enabled = True
the code above is how i encrypt and store it in the databse. kindly help me how to decrypt it. it would be a real help for me. thanks folks... :)