예제 #1
0
        /// <summary>
        /// 匹配MD5值
        /// </summary>
        /// <param name="matchFile">匹配文件</param>
        /// <param name="realMd5Value">真实MD5值</param>
        public bool MatchMd5(string matchFile, string realMd5Value)
        {
            bool       bRet    = false;
            Md5Encrypt encrypt = new Md5Encrypt();

            try
            {
                using (var stream = new System.IO.StreamReader(matchFile))
                {
                    string inputString = stream.ReadToEnd();
                    string md5Value    = encrypt.Output(inputString, System.Text.Encoding.Default).ToUpper();
                    if (md5Value == realMd5Value.ToUpper())
                    {
                        // 匹配正确
                        bRet = true;
                    }
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine("MatchMd5 Exception: " + e.Message);
                Settings.RuntimeLog.Severe("MatchMd5 Exception: " + e.ToString());
            }
            encrypt = null;
            return(bRet);
        }