The NET Framework 4.5 ADO database connection supports the use of SecureString memory flow mode for confidential text . Once this type of operation is used, the text encryption is private and can be removed from the computer's memory when it is no longer needed. SecureString This class cannot be inherited. Here are some demos
private void Login_click (object sender, EventArgs e) {//login parameter string userName = Username.te xt SecureString password = SecureString (password.text); Password. Makereadonly (); Sqlcredential provides a more secure way to specify a logon attempt password that uses SQL Server authentication. Sqlcredential credential = new Sqlcredential (userName, password); Database connection using (SqlConnection conn = new SqlConnection ("server= (local); Initial catalog=database;")) {Conn. credential = credential; Conn. Open (); MessageBox.Show ("Connection succeeded"); Conn. Close (); }}///<summary>///Confidential text///</summary>//<param name= "text" > Confidential word String </param>///<returns></returns> Private SecureString SecureString (string text) { char[] PChar = text. ToCharArray (); SecureString Password = new SecurestriNg (); foreach (char c in PChar) {password. Appendchar (c); } return password; }
When you enter a correct SQL login user name and password, the output is the same
Throws an SQL exception when an incorrect user name or password is entered
The next article continues to explain the new features of the net Framework 4.5