/// <summary>
        ///生成授权码
        /// </summary>
        /// <param name="mac">网卡物理地址</param>
        /// <param name="expireTime">到时时间</param>
        /// <param name="category">授权类型0=开发 1=产品</param>
        /// <param name="sPublicKey">公钥</param>
        /// <returns></returns>
        public static string Encrypt(string mac, DateTime expireTime, int category, string sPublicKey)
        {
            var now        = DateTime.Now.ToString("yyyyMMddHHmmss");
            var macFormart = mac.Replace(":", "").Replace("-", "");
            var ran        = new Random();
            var randKey    = ran.Next(1000, 9999);
            //14+12+10+1+4 防止同一个授权信息生成相同的授权码
            string source = $"{now}{macFormart}{expireTime.ToString("yyyy-MM-dd")}{category}{randKey}";

            return(RSACryptoService.EncryptString(source, sPublicKey));
        }
        /// <summary>
        /// 解密授权码
        /// </summary>
        /// <param name="sSource">授权码</param>
        /// <param name="sPrivateKey">私钥</param>
        /// <returns>授权信息</returns>
        private static AuthorizationCode Decrypt(string sSource, string sPrivateKey)
        {
            var authorizationCode = new AuthorizationCode();
            var code = RSACryptoService.DecryptString(sSource, sPrivateKey);

            authorizationCode.Mac      = code.Substring(14, 12);
            authorizationCode.Category = Convert.ToInt32(code.Substring(36, 1));
            DateTime expireTime;

            DateTime.TryParse(code.Substring(26, 10), out expireTime);
            authorizationCode.ExpireTime = expireTime;
            return(authorizationCode);
        }
        /// <summary>
        /// 解密授权码
        /// </summary>
        /// <param name="sSource">授权码</param>
        /// <param name="publicKey">公钥</param>
        /// <returns>授权信息</returns>
        public static AuthorizationCode Decrypt(string sSource, string publicKey)
        {
            var authorizationCode = new AuthorizationCode();
            var code = RSACryptoService.DecryptString(sSource, publicKey);

            string[] authorizationCodes = code.Split(new string[] { Flag }, StringSplitOptions.RemoveEmptyEntries);
            if (authorizationCodes.Length < 5)
            {
                return(authorizationCode);
            }

            authorizationCode.CheckCode = authorizationCodes[1];
            authorizationCode.Category  = Convert.ToInt16(authorizationCodes[3]);
            DateTime expireTime;

            DateTime.TryParse(authorizationCodes[2], out expireTime);
            authorizationCode.ExpireTime = expireTime;

            return(authorizationCode);
        }