コード例 #1
0
 public static byte[] LocalUnprotectData(byte[] data)
 {
     if (data == null)
     {
         return(null);
     }
     return(DataProtectionLocal.UnprotectData(data, 1));
 }
コード例 #2
0
 public static byte[] LocalProtectData(byte[] data)
 {
     if (data == null)
     {
         return(null);
     }
     return(DataProtectionLocal.ProtectData(data, 1 | DataProtectionLocal.m_dwProtectionFlags));
 }
コード例 #3
0
 public byte[] ProtectData(string unprotectedData, string tag)
 {
     if (unprotectedData == null)
     {
         return(null);
     }
     byte[] bytes = Encoding.Unicode.GetBytes(unprotectedData);
     return(DataProtectionLocal.LocalProtectData(bytes));
 }
コード例 #4
0
        public static string LocalProtectData(string data)
        {
            if (data == null)
            {
                return(null);
            }
            byte[] bytes  = Encoding.Unicode.GetBytes(data);
            byte[] array  = DataProtectionLocal.LocalProtectData(bytes);
            string result = null;

            if (array != null)
            {
                result = Convert.ToBase64String(array);
            }
            return(result);
        }
コード例 #5
0
 public string UnprotectDataToString(byte[] protectedData, string tag)
 {
     if (protectedData == null)
     {
         return(null);
     }
     byte[] array = DataProtectionLocal.LocalUnprotectData(protectedData);
     if (array == null)
     {
         return(null);
     }
     if (protectedData.Length == 0)
     {
         return(string.Empty);
     }
     return(Encoding.Unicode.GetString(array));
 }
コード例 #6
0
        public static string LocalUnprotectData(string data)
        {
            if (data == null)
            {
                return(null);
            }
            byte[] data2 = Convert.FromBase64String(data);
            byte[] array = DataProtectionLocal.LocalUnprotectData(data2);
            string text  = null;

            if (array != null)
            {
                text = Encoding.Unicode.GetString(array);
                if (text != null && text.Length > 0 && text[text.Length - 1] == '\0')
                {
                    text = text.Remove(text.Length - 1);
                }
            }
            return(text);
        }