NET Framework 4.5 new Feature (a) connection encryption protection for the database.

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.