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();
    }
示例#2
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     lbl_decrypted.Text = CryptLib.Decrypt(txt_decr.Text);
 }
示例#3
0
 /// <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; }
 }
示例#4
0
 /// <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; }
 }