private static void Main(string[] args) { CryptLib crypt = new CryptLib("password", "iv"); string encryptedText = crypt.Encrypt("this is a secret message"); Console.WriteLine(encryptedText); string decryptedText = crypt.Decrypt(encryptedText); Console.WriteLine(decryptedText); Console.ReadLine(); }
protected void Button2_Click(object sender, EventArgs e) { lbl_decrypted.Text = CryptLib.Decrypt(txt_decr.Text); }
/// <summary> /// Get the connection for MySQL Server /// </summary> /// <returns></returns> /// <exception cref="Exception"></exception> public string GetConnectionStringForMySql() { try { CryptLib aDTool = new CryptLib(); return(String.IsNullOrEmpty(Port) ? $"database={this.Database}; server={this.ServerName}; SslMode={this.SslMode}; user id={this.User}; pwd={aDTool.Decrypt(this.Password)}" : $"database={this.Database}; server={this.ServerName}; Port={this.Port}; SslMode={this.SslMode}; user id={this.User}; pwd={aDTool.Decrypt(this.Password)}"); } catch (Exception ex) { throw ex; } }
/// <summary> /// Get the connection For SQL Server /// </summary> /// <returns></returns> /// <exception cref="Exception"></exception> public string GetConnectionStringForSql() { try { CryptLib aDTool = new CryptLib(); return(Convert.ToBoolean(this.IntegratedSecurity ?? "False") ? $"Data Source={this.ServerName};Initial Catalog={this.Catalog};Integrated Security=True;Pooling=False;MultipleActiveResultSets=True;" : $"Data Source={this.ServerName};Initial Catalog={this.Catalog};User Id={this.User};Password={aDTool.Decrypt(this.Password)};Connection Timeout={this.ConnectionTimeOut};Pooling=False;MultipleActiveResultSets=True;"); } catch (Exception ex) { throw ex; } }