Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 对于中小型公司';MSSQL数据库_C#_Sql Server_Encryption - Fatal编程技术网

C# 对于中小型公司';MSSQL数据库

C# 对于中小型公司';MSSQL数据库,c#,sql-server,encryption,C#,Sql Server,Encryption,我希望实现加密,因为有多个人可以访问数据库,而且我的公司希望在我的应用程序中存储人员(敏感)信息。为了创建一些分离和安全性,我希望实现加密,理想情况下使用他们选择的“密钥”对一个SQL表中的数据进行加密 我知道我自己做这件事,我会错过一个技巧,经过尝试和测试可能是最好的,特别是对于我们这样规模的公司,我们不需要太担心黑客,因为数据库无法从外部访问。刚好能把感兴趣的人挡在外面 我想知道什么样的安全级别是合适的,而且我也有点不知所措,甚至谷歌都不知道我需要在第三方插件中使用什么样的加密,因为他们都想

我希望实现加密,因为有多个人可以访问数据库,而且我的公司希望在我的应用程序中存储人员(敏感)信息。为了创建一些分离和安全性,我希望实现加密,理想情况下使用他们选择的“密钥”对一个SQL表中的数据进行加密

我知道我自己做这件事,我会错过一个技巧,经过尝试和测试可能是最好的,特别是对于我们这样规模的公司,我们不需要太担心黑客,因为数据库无法从外部访问。刚好能把感兴趣的人挡在外面

我想知道什么样的安全级别是合适的,而且我也有点不知所措,甚至谷歌都不知道我需要在第三方插件中使用什么样的加密,因为他们都想销售他们的产品,他们都会说他们自己的很好


我能找到的大多数其他问题和建议的“类似问题”都涉及到数据传输加密、哈希或ASP.NET

扰码信息可以使用对称(Rijndael)密钥完成,但我不知道使用SQL update的应用程序的性能有多大提高


所有的安全性实际上都是关于提高标准和可用性的权衡。有了加密,这里有很多选择,但实际上都归结为密钥管理

谁有解密的钥匙

它们是如何储存的

对您的应用程序数据的暴力攻击(例如,他们通过截获您的联邦快递到铁山,从而获得加密SQL Server数据库的备份磁带)不太可能是对密钥管理系统的内部攻击——例如,员工或开发人员更改程序以解密和转储数据

由于应用程序通常必须在任何时候向授权用户解密这些数据,因此我可能会重点关注敏感列的可见性以及允许首先访问这些列的角色,然后担心加密这些列

SQL Server仅为数据和连接提供透明加密。如果用户具有对表的
SELECT*
访问权限,则此选项无效。在SQL Server不知情的情况下自己在列中对其进行加密可能会有问题。例如,如果有一列是敏感的薪资数据,如果在一列中对其进行加密,则不能只运行
SELECT Employee,SUM(pay)GROUP BY Employee


首先,我要确保您在应用程序中识别了用户和角色,审查了他们拥有何种访问权限,并确保所有数据库连接都使用适当的角色。

我个人建议使用AES,因为AES非常容易实现,而且由于它是敏感的,个人数据将提供足够的加密,以防人们进入,不像DES那样

如果您想从技术上了解AES的工作原理,本文将深入探讨AES: 以及随附的基本示例:

下面是一个关于如何实现它的非常清晰的示例:

拆卸示例(防止链路旋转)

使用系统;
使用System.IO;
使用System.Security.Cryptography;
名称空间RijndaelManaged_示例
{
类RijndaelMemorye示例
{
公共静态void Main()
{
尝试
{
string original=“这里有一些要加密的数据!”;
//创建RijndaelManaged的新实例
//这将生成一个新的密钥和初始化
//载体(IV)。
RijndaelManaged myRijndael=新的RijndaelManaged();
//将字符串加密为字节数组。
byte[]encrypted=encryptStringToBytes_AES(原始,myRijndael.Key,myRijndael.IV);
//将字节解密为字符串。
字符串往返=decryptStringFromBytes_AES(加密,myRijndael.Key,myRijndael.IV);
//显示原始数据和解密数据。
WriteLine(“原件:{0}”,原件);
WriteLine(“往返:{0}”,往返);
}
捕获(例外e)
{
WriteLine(“错误:{0}”,e.Message);
}
}
静态字节[]加密StringToBytes_AES(字符串明文,字节[]密钥,字节[]IV)
{
//检查参数。

if(plainText==null | | plainText.Length('Right'是您想要的,而不是此处的'write'))加密不是解决方案中最好或最重要的部分。如果你希望黑客访问数据库,那么除了加密密码之外,你还有其他问题。同样重要,甚至更重要的是,保护系统/数据库的安全,使其无法访问。好吧,我的意图是“扰乱”信息并解扰“我的C#app中的信息,并将“扰扰”信息保存在数据库中,我们有一些人在DB上工作,我们希望他们在DB上进行开发,但只是“扰扰”敏感数据stuff@Kieren约翰斯通,密码根本不需要存储:加密或纯文本。你应该存储一个(盐渍的)密码的加密散列和身份验证应该简单地比较散列。这对于诸如密码之类的身份验证来说听起来是合理的,但是对于用户输入的存储数据来说呢?加密的形式取决于数据,而不是公司的规模。关于加密数据在一个并非真正愚蠢的系统中的有用性降低的观点是好的存储单元。
using System;
using System.IO;
using System.Security.Cryptography;

namespace RijndaelManaged_Examples
{
    class RijndaelMemoryExample
    {
        public static void Main()
        {
            try
            {

                string original = "Here is some data to encrypt!";

                // Create a new instance of the RijndaelManaged
                // class.  This generates a new key and initialization 
                // vector (IV).
                RijndaelManaged myRijndael = new RijndaelManaged();

                // Encrypt the string to an array of bytes.
                byte[] encrypted = encryptStringToBytes_AES(original, myRijndael.Key, myRijndael.IV);  

                // Decrypt the bytes to a string.
                string roundtrip = decryptStringFromBytes_AES(encrypted, myRijndael.Key, myRijndael.IV);

                //Display the original data and the decrypted data.
                Console.WriteLine("Original:   {0}", original);
                Console.WriteLine("Round Trip: {0}", roundtrip);

            }
            catch (Exception e)
            {
                Console.WriteLine("Error: {0}", e.Message);
            }
        }

        static byte[] encryptStringToBytes_AES(string plainText, byte[] Key, byte[] IV)
        {
            // Check arguments.
            if (plainText == null || plainText.Length <= 0)
                throw new ArgumentNullException("plainText");
            if (Key == null || Key.Length <= 0)
                throw new ArgumentNullException("Key");
            if (IV == null || IV.Length <= 0)
                throw new ArgumentNullException("Key");

            // Declare the streams used
            // to encrypt to an in memory
            // array of bytes.
            MemoryStream    msEncrypt   = null;
            CryptoStream    csEncrypt   = null;
            StreamWriter    swEncrypt   = null;

            // Declare the RijndaelManaged object
            // used to encrypt the data.
            RijndaelManaged aesAlg      = null;

            try
            {
                // Create a RijndaelManaged object
                // with the specified key and IV.
                aesAlg = new RijndaelManaged();
                aesAlg.Key = Key;
                aesAlg.IV = IV;

                // Create a decrytor to perform the stream transform.
                ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);

                // Create the streams used for encryption.
                msEncrypt = new MemoryStream();
                csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write);
                swEncrypt = new StreamWriter(csEncrypt);

                //Write all data to the stream.
                swEncrypt.Write(plainText);

            }
            finally
            {
                // Clean things up.

                // Close the streams.
                if(swEncrypt != null)
                    swEncrypt.Close();
                if (csEncrypt != null)
                    csEncrypt.Close();
                if (msEncrypt != null)
                    msEncrypt.Close();

                // Clear the RijndaelManaged object.
                if (aesAlg != null)
                    aesAlg.Clear();
            }

            // Return the encrypted bytes from the memory stream.
            return msEncrypt.ToArray();

        }

        static string decryptStringFromBytes_AES(byte[] cipherText, byte[] Key, byte[] IV)
        {
            // Check arguments.
            if (cipherText == null || cipherText.Length <= 0)
                throw new ArgumentNullException("cipherText");
            if (Key == null || Key.Length <= 0)
                throw new ArgumentNullException("Key");
            if (IV == null || IV.Length <= 0)
                throw new ArgumentNullException("Key");

            // TDeclare the streams used
            // to decrypt to an in memory
            // array of bytes.
            MemoryStream    msDecrypt   = null;
            CryptoStream    csDecrypt   = null;
            StreamReader    srDecrypt   = null;

            // Declare the RijndaelManaged object
            // used to decrypt the data.
            RijndaelManaged aesAlg      = null;

            // Declare the string used to hold
            // the decrypted text.
            string plaintext = null;

            try
            {
                // Create a RijndaelManaged object
                // with the specified key and IV.
                aesAlg = new RijndaelManaged();
                aesAlg.Key = Key;
                aesAlg.IV = IV;

                // Create a decrytor to perform the stream transform.
                ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);

                // Create the streams used for decryption.
                msDecrypt = new MemoryStream(cipherText);
                csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read);
                srDecrypt = new StreamReader(csDecrypt);

                // Read the decrypted bytes from the decrypting stream
                // and place them in a string.
                plaintext = srDecrypt.ReadToEnd();
            }
            finally
            {
                // Clean things up.

                // Close the streams.
                if (srDecrypt != null)
                    srDecrypt.Close();
                if (csDecrypt != null)
                    csDecrypt.Close();
                if (msDecrypt != null)
                    msDecrypt.Close();

                // Clear the RijndaelManaged object.
                if (aesAlg != null)
                    aesAlg.Clear();
            }

            return plaintext;

        }
    }
}