public static SqlBinary Protect(string clearText)
    {
        var dp      = new DataProtector(x509);
        var encrypt = dp.ProtectBuffer(clearText);

        return(new SqlBinary(encrypt));
    }
Beispiel #2
0
        public void TestProtectNullString()
        {
            var dt          = new DataProtector(_cert);
            var bytes       = dt.ProtectBuffer(null);
            var unencrypted = dt.UnprotectBuffer(bytes);

            Assert.Null(unencrypted);
        }
Beispiel #3
0
        public void TestProtectEmptyString()
        {
            var dt          = new DataProtector(_cert);
            var bytes       = dt.ProtectBuffer(String.Empty);
            var unencrypted = dt.UnprotectBuffer(bytes);

            Assert.Equal(String.Empty, unencrypted);
        }
Beispiel #4
0
        public void TestProtectUnProtect(string clearText)
        {
            var dt          = new DataProtector(_cert);
            var bytes       = dt.ProtectBuffer(clearText);
            var unencrypted = dt.UnprotectBuffer(bytes);

            Assert.Equal(clearText, unencrypted);
        }