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


            MsgBox("Email Has Been Successfully Added!", MsgBoxStyle.Information)




            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... :)

5 Years
Discussion Span
Last Post by lolafuertes

ciphertext = Encrypt(txtEmailPass.Text)

Wich encrypt function are you using? Is written by your self? or is some of the predefined System.Security.Cryptography? Which one?

Did you already read this?

Let us know


hi lola... actually its a predefined. i used the System.Security.Cryptography. Yeah I saw the example u gave me and i have the exact one..I have the code on how to decrypt actually, but i dunno how to apply it to that password column only and decrypt the whole databases password. :) any ideas?


You need to read each row in the table, then decrypt the password field.

You can do it by using a data adapter to fill a datatable, then using a foreach loop analyze each row in the datatable, decrypt the password and update the datatable row.

Finally, use the datatable as datasource for your datagrid.

Hope this helps

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.