title: Encrypting datagridview values C#
body: <p>I'm working on a winforms application that let the user fill in account and password information in a datagridview, the datasource is a datatable which will be connected to a mysql server using the .net mysql connector.</p>
  
  <p>When the user saves the datatable the data needs to be encrypted to the mysql database, so incase someone hacks into the mysql server the data is useless.</p>
  
  <p>For encrypting and decrypting I use a class called SimpleAES (<a href="https://stackoverflow.com/questions/165808/simple-two-way-encryption-for-c-sharp">Simple insecure two-way &quot;obfuscation&quot; for C#</a>)</p>
  
  <p>This works great for textboxes and such, but how can I loop thru a datagridview to encrypt all the values given by the user?</p>
  
  <p>I tried the following.</p>
  
  <pre><code>    private void encryptAccounts()
          {
              SimpleAES simpleAES1 = new SimpleAES();
  
              string password;
  password= dataGridViewAccounts[4,0].Value.ToString();
  
              dataGridViewAccounts[4,0].Value = simpleAES1.EncryptToString(password);
          }
  </code></pre>
  
  <p>This will only encrypt the password for the first row, how can I create a loop for every row</p>