C # EF encrypted connection database connection string

Not much to say, directly on the code

    public  partial  class Model1: the DbContext 
    { 
        Private  static  String connStr = "" ;
         public Model1 (): Base ( " the Data .; the Initial Cataog the Source = = GameDb; User ID = SA; password = 123456 " ) // Default easily fill a standard the connection string, if not a standard behind you set the connection string to be wrong, the specific reasons we are interested to get to the bottom of it 
        { IF (connStr == "" ) 
            { 
                connStr = ConfigurationManager.ConnectionStrings [ " Model1 " ] .ConnectionString; 
                connStr = SymmetricMethod.Decrypto(connStr);
            }
            base.Database.Connection.ConnectionString = connStr;
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
        }
    }

web.config as follows

 <add name="Model1" connectionString="zgtsMV7VlXojlkp2VhEQvCsN6Pq/RsadZKfvOgqRWKPtBL8/x+2yBuSiWjfkMueEcAbFVTrI094JVLn28NnyiHlAqUl8q8g4T/ybEi4gPQPVEdUfg31xF8NLgWDCAGR9Tw+7/VTm/WRpBHxrpCwUwggB35QNgqkXo+1SQ6OmpqhrNdSuPrlzh1UoOHP/p55WrVL2TNOZ5n4v6CUmODdTVw==" providerName="System.Data.SqlClient" />
  </connectionStrings>

Which SymmetricMethod.Decrypto decryption algorithm, as the encryption and decryption algorithms, now own Baidu

Guess you like

Origin www.cnblogs.com/yibey/p/11387887.html