English 中文(简体)
2008年服务器的加密数据
原标题:Decrypt Data From SQL Server 2008 R2

I need some help translating this procedure (see below) to Entity Framework 4.0. Does anyone have any suggestions of how to port this over. The target project includes; Silverlight 4, WCF RIA Services, EF 4.0, SQL Server 2008 R2.

我的唯一要求是,它需要列入管理法,而不是储存程序。

    Try 
    {
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = cn;
        cmd.CommandType = CommandType.Text;
        string sql = "OPEN SYMMETRIC KEY " + this._encryptKey;
        sql += " DECRYPTION BY CERTIFICATE " + this._encrpytCert; 
        sql += " SELECT TOP (1) CONVERT(nvarchar(50),DECRYPTBYKEY(Field1)) AS Name";
        sql += " FROM Table3"; 
        sql += " ORDER BY CONVERT(nvarchar(50),DECRYPTBYKEY(Field1))";
        cmd.CommandText = sql;
        Name = (String)cmd.ExecuteScalar();
        bRtn = false;
    }
        catch (Exception ex)
    {
        System.Diagnostics.Debug.Print(ex.ToString());
    }

Please let me know how I should set this up and thanks!

问题回答

可以通过实体框架来管理询问,并通过使用ObjectContext.ExecuteSshopery<>)功能(见

然而,不幸的是,我看不出有什么办法可以绕过来发表T-SQL声明。 虽然你可以通过SqlFuntions 级,但没有任何功能将服务器转换成密码功能,更不用说《框架实体》赢得了对钥匙开放的声明。

为了在查询敏感数据之前进行加密,你需要做的是利用电离层电离层传输。

页: 1

  • connection.Open();
  • connection.BeginTransaction();
  • execute your "OPEN SYMMETRIC KEY..." command or stored procedure with ExecuteStoreCommand execute your sensitive data queries, stored procedures etc.
  • Commit or Rollback you transaction if required

由于你已经开始了 d交易,这迫使法国保持同样的 d子关系,因此这是有意义的,因为作为同一 d交易的一部分,你可能会执行整个SP的bu。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签