public void Decrypt_ShouldDecryptEncryptedString_ReturnsString() { // Arrange const string encryptedKey = "RbOehAehsS7MYbKpbCbvepBVjtlsFbNU"; const string resultString = "This is a test string"; // Act var decryptedString = EPMData.Decrypt(encryptedKey); // Assert Assert.AreEqual(resultString, decryptedString); }
private string getReportingConnection(SPWeb web) { string sCn = ""; using (SqlConnection cn = CreateConnection()) { try { cn.Open(); using (var cmd = new SqlCommand( "SELECT Username, Password, DatabaseServer, DatabaseName from RPTDATABASES where SiteId=@SiteId", cn)) { cmd.Parameters.AddWithValue("@SiteId", web.Site.ID); using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.Read()) { sCn = "Data Source=" + dr.GetString(2) + ";Initial Catalog=" + dr.GetString(3); if (!dr.IsDBNull(0) && dr.GetString(0) != "") { sCn += ";User ID=" + dr.GetString(0) + ";Password="******";Trusted_Connection=True"; } } } } } catch (Exception ex) { bErrors = true; sbErrors.Append("<font color=\"red\">Error: " + ex.Message + "</font><br>"); } } return(sCn); }