Exemple #1
0
        /// <summary>
        /// 将当前DataTable转换为特殊字符分隔的字符串
        /// </summary>
        /// <param name="table"></param>
        /// <param name="aes"></param>
        /// <param name="encrypt_columns"></param>
        /// <returns></returns>
        public static string toContentString(DataTable table, AESCryptoBase aes, ArrayList encrypt_columns)
        {
            string res = "";

            for (int i = 0; i < table.Columns.Count; i++)
            {
                res += table.Columns[i].ColumnName + Convert.ToChar(31);
            }
            res = res.TrimEnd(Convert.ToChar(31)) + Convert.ToChar(30);
            for (int i = 0; i < table.Rows.Count; i++)
            {
                for (int j = 0; j < table.Columns.Count; j++)
                {
                    if (arrayListContains(encrypt_columns, j))//加密列,做加密处理
                    {
                        res += aes.encrypt128(table.Rows[i][j].ToString()) + Convert.ToChar(31);
                    }
                    else//非加密列,常规处理
                    {
                        res += table.Rows[i][j].ToString() + Convert.ToChar(31);
                    }
                }
                res = res.TrimEnd(Convert.ToChar(31)) + Convert.ToChar(30);
            }
            res = res.TrimEnd(Convert.ToChar(30));
            return(res);
        }
Exemple #2
0
 /// <summary>
 /// 读取加密后的权限信息
 /// </summary>
 /// <param name="content"></param>
 public void setPrivilegeContent(string content)
 {
     if (_privilege_content == content)
     {
         return;
     }
     _privilege_content = content;
     string[] parts = new AESCryptoBase().decrypt256(_privilege_content).Split(Convert.ToChar(29));
     try
     {
         account_name = parts[0];
         for (int i = 1; i < parts.Length; i++)
         {
             string[] subs = parts[i].Split(Convert.ToChar(30));
             try
             {
                 var group = groupWithName(subs[0]);
                 if (group != null)
                 {
                     group.setPrivilegeContent(subs[1]);
                 }
             }
             catch { }
         }
     }
     catch { }
 }
Exemple #3
0
 public static DataTable fromContentString(string content_string, AESCryptoBase aes, ArrayList encrypt_columns)
 {
     try
     {
         if (content_string.Trim() == "")
         {
             return(new DataTable());
         }
         string[] rows = content_string.Split(Convert.ToChar(30));
         if (rows[0].Trim() == "")
         {
             return(new DataTable());
         }
         string[]  headers = rows[0].Split(Convert.ToChar(31));
         DataTable res     = new DataTable();
         for (int i = 0; i < headers.Length; i++)
         {
             res.Columns.Add(headers[i]);
         }
         for (int i = 1; i < rows.Length; i++)
         {
             try
             {
                 string[] rowcontent = rows[i].Split(Convert.ToChar(31));
                 DataRow  dr         = res.NewRow();
                 for (int j = 0; j < rowcontent.Length; j++)
                 {
                     try
                     {
                         if (arrayListContains(encrypt_columns, j))
                         {
                             dr[j] = aes.decrypt128(rowcontent[j]);
                         }
                         else
                         {
                             dr[j] = rowcontent[j];
                         }
                     }
                     catch { }
                 }
                 res.Rows.Add(dr);
             }
             catch { }
         }
         return(res);
     }
     catch { return(new DataTable()); }
 }
 /// <summary>
 /// 将当前DataTable转换为特殊字符分隔的字符串
 /// </summary>
 /// <param name="data"></param>
 /// <param name="aes"></param>
 /// <param name="encrypt_columns"></param>
 /// <returns></returns>
 public static string toContentString(this DataTable data, AESCryptoBase aes, ArrayList encrypt_columns)
 {
     return(DataTableUtil.toContentString(data, aes, encrypt_columns));
 }