Exemplo n.º 1
0
        public static RequestCodeInfo GetRequsetCodeInfo(string requestCode)
        {
            RequestCodeInfo info = new RequestCodeInfo();
            string          code = EncryptionDes.Decrypt(requestCode);

            string[] parts = code.Split(new string[] { TGljZW5zZQInfo.SYMBOL }, StringSplitOptions.None);
            info.ProjectName = parts[0];
            info.RequestDate = parts[1];
            info.EndDate     = parts[2];

            return(info);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 校验申请码
        /// </summary>
        /// <param name="requestCode"></param>
        /// <returns></returns>
        public static bool CheckRequestCode(string requestCode, out RequestCodeInfo requestCodeInfo, out string errMsg)
        {
            errMsg          = "";
            requestCodeInfo = new RequestCodeInfo();
            if (string.IsNullOrWhiteSpace(requestCode))
            {
                errMsg = "申请码为空";
                return(false);
            }

            try
            {
                //RSA(项目名称+申请日期+结束日期+硬盘序列号/CPU序列号+随机数+整个MD5)
                string code = "";
                try
                {
                    code = EncryptionDes.Decrypt(requestCode);
                }
                catch (Exception)
                {
                    errMsg = "申请码不正确";
                    return(false);
                }


                string[] parts = code.Split(new string[] { TGljZW5zZQInfo.SYMBOL }, StringSplitOptions.None);
                if (parts.Length != 6)
                {
                    errMsg = "申请码结构不符合要求";
                    return(false);
                }

                string md5    = parts[5];
                string newMd5 = (parts[0] + TGljZW5zZQInfo.SYMBOL + parts[1] + TGljZW5zZQInfo.SYMBOL + parts[2] + TGljZW5zZQInfo.SYMBOL + parts[3] + TGljZW5zZQInfo.SYMBOL + parts[4]).Md5();
                if (md5 != newMd5)
                {
                    errMsg = "申请码校验有误";
                    return(false);
                }

                //if (parts[0] != projectName)
                //{
                //    errMsg = "申请的项目名称不符合";
                //    return false;
                //}
                requestCodeInfo.ProjectName = parts[0];

                //if (string.Compare(parts[1], PublicUtils.GetSysDateTimeStr())>=0)
                //{
                //    errMsg = "申请日期晚于当前时间";
                //    return false;
                //}
                requestCodeInfo.RequestDate = parts[1];

                //if (string.Compare(parts[2], PublicUtils.GetSysDateTimeStr()) < 0)
                //{
                //    errMsg = "申请码已失效";
                //    return false;
                //}
                requestCodeInfo.EndDate = parts[2];

                requestCodeInfo.UniqueId = parts[3];
            }
            catch (Exception e)
            {
                errMsg = "申请码校验出现异常,其原因如下:" + e.Message;
                return(false);
            }

            return(true);
        }