Encrypt and decrypt records with button

  • Thread starter Thread starter Zeme123
  • Start date Start date
Z

Zeme123

Guest
Hello,

I'm using Visual Studio 2013. I'm trying to create a button that when clicked encrypts the data in a database as I'm exporting it and save it to a file and provide a decrypt key for the decryption part.

This is my code for the export button

private void export_btn_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook workbook = app.Workbooks.Add(Type.Missing);
Microsoft.Office.Interop.Excel.Worksheet worksheet = null;
worksheet = workbook.Sheets["Sheet1"];
worksheet = workbook.ActiveSheet;
worksheet.Name = "PatientDetails";

for (int i = 1; i < dataGridView1.Columns.Count+1; i++)
{
worksheet.Cells[1,i] = dataGridView1.Columns[i - 1].HeaderText;
}

for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
for (int j = 0; j < dataGridView1.Columns.Count; j++)
{
worksheet.Cells[i + 2, j + 1] = dataGridView1.Rows.Cells[j].Value.ToString();
}
}

var saveFileDialoge = new SaveFileDialog();
saveFileDialoge.FileName = "output";
saveFileDialoge.DefaultExt = ".xlsx";
if (saveFileDialoge.ShowDialog()==DialogResult.OK)
{
workbook.SaveAs(saveFileDialoge.FileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
app.Quit();
}

Any suggestions where I can put encryption algorithms (preferably AES/DES or paillier if possible)?

Thanks

Continue reading...
 
Back
Top