Пример #1
0
        // Des Encode & Decode
        //private static         // Create a new DES _key.
        //DESCryptoServiceProvider DES_Key = new DESCryptoServiceProvider();

        /// <summary>
        /// 加密和解密字符串
        /// </summary>
        /// <param name="strText">要加密或者解密的字符串</param>
        /// <param name="bEncrypt">true-加密,false-解密</param>
        /// <returns>如果成功,则返回结果字符串;否则为null。</returns>
        public string EncodeDecode(string strText, bool bEncrypt)
        {
            try
            {
                if (bEncrypt)
                {
                    return(Encrypt(strText));
                }
                else
                {
                    return(Decrypt(strText));
                }
            }
            catch
            {
                log.Error("无法完成加密或者解密操作。" + strText);
                return(null);
            }
        }
Пример #2
0
 /// <summary>
 /// 以DEBUG级别将信息输出到文件日志
 /// </summary>
 /// <param name="strMsg">要输出的信息</param>
 /// <param name="req">当前的请求对象,可以为null</param>
 public static void LogError(string strMsg, HttpContext context)
 {
     try
     {
         // get the default FileLogger instance
         AbstractLogger logger = AbstractLogger.GetLogger(typeof(Function));
         if (logger == null)
         {
             return;
         }
         logger.Error(
             string.Format("[{0}] by [{1}]\r\n{2}\r\n",
                           context == null ? "N/A" : context.Request.RawUrl,
                           context == null ? "N/A" : context.Request.UserHostAddress,
                           strMsg));
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.Assert(false, ex.Message);
     }
 }