private void bGo_Click(object sender, EventArgs e) { try { //Make sure that we have a value if (string.IsNullOrWhiteSpace(tSourceString.Text)) throw new ApplicationException("No source string provided."); Rijndael rijndael = new Rijndael(_key, _iv); string input = tSourceString.Text.Trim(); string output; if (rbEncrypt.Checked) { output = rijndael.Encrypt(input); } else { output = rijndael.Decrypt(tSourceString.Text); } tOutputString.Text = output; } catch (Exception ex) { DisplayError(ex.Message); } }
private void AssignConnectionString() { //Attempt to retrieve the connection string from the web.config file ConnectionStringSettings connStrSettings; if ((connStrSettings = ConfigurationManager.ConnectionStrings["MsSqlRepository"]) == null) throw new ConnectionStringAssignmentException(); //We expect the connection string to be encrypted, so decrypt it string encryptedConnStr = connStrSettings.ConnectionString; Rijndael rijndael = new Rijndael(_key, _iv); _connectionString = rijndael.Decrypt(encryptedConnStr); }