예제 #1
0
 /// <summary>
 /// 生成授权码
 /// </summary>
 /// <param name="regCode">注册码</param>
 /// <param name="expire">过期时间</param>
 /// <returns></returns>
 public string GenerateLicense(string regCode = null, DateTime expire = default(DateTime))
 {
     try
     {
         var expireDateTime = expire.ToBinary() > 0 ? expire : DefaultExpireDateTime;
         return(StringEncrypter.Encrypt(YusDate.DateTimeToUnix(expireDateTime) + "_" + (regCode ?? RegCode).Trim()));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(null);
     }
 }
예제 #2
0
 /// <summary>
 /// 获取授权码的过期时间
 /// </summary>
 /// <param name="licence">授权码</param>
 /// <returns></returns>
 public DateTime ExpireDateTime(string licence)
 {
     try
     {
         var licInfo  = StringEncrypter.Decrypt(licence);
         var licInfos = licInfo.Split('_');
         return(YusDate.UnixToDate(Convert.ToInt64(licInfos[0])));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(default(DateTime));
     }
 }