针对保存进数据库的部分字段数据加密
采用什么加解密方式相对好点

解决方案 »

  1.   

    http://topic.csdn.net/u/20090110/13/e28ea3f1-ff3a-4cc9-84b6-18e4e426b46f.html
      

  2.   

    用存储过程加密解密:http://blog.sqlauthority.com/2009/04/28/sql-server-introduction-to-sql-server-encryption-and-symmetric-key-encryption-tutorial-with-script/然后发布的时候,用Sqlshield对存储过程进行加密:
    http://www.sql-shield.com/index.php
      

  3.   

      /// <summary> 
            /// 加密方法 
            /// </summary> 
            /// <param name="Source">待加密的串</param> 
            /// <returns>经过加密的串</returns> 
            public string Encrypto(string Source)
            {
                byte[] bytIn = UTF8Encoding.UTF8.GetBytes(Source);
                MemoryStream ms = new MemoryStream();
                mobjCryptoService.Key = GetLegalKey();
                mobjCryptoService.IV = GetLegalIV();
                ICryptoTransform encrypto = mobjCryptoService.CreateEncryptor();
                CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Write);
                cs.Write(bytIn, 0, bytIn.Length);
                cs.FlushFinalBlock();
                ms.Close();
                byte[] bytOut = ms.ToArray();
                return Convert.ToBase64String(bytOut);
            }
            /// <summary> 
            /// 解密方法 
            /// </summary> 
            /// <param name="Source">待解密的串</param> 
            /// <returns>经过解密的串</returns> 
            public string Decrypto(string Source)
            {
                byte[] bytIn = Convert.FromBase64String(Source);
                MemoryStream ms = new MemoryStream(bytIn, 0, bytIn.Length);
                mobjCryptoService.Key = GetLegalKey();
                mobjCryptoService.IV = GetLegalIV();
                ICryptoTransform encrypto = mobjCryptoService.CreateDecryptor();
                CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Read);
                StreamReader sr = new StreamReader(cs);
                return sr.ReadToEnd();
            }