Example #1
0
        public void Base64Test()
        {
            string plainText = "hello world";
            string encrypted = Encryption.Base64Encrypt(plainText);
            string decrypted = Encryption.Base64Decrypt(encrypted);

            Assert.NotEqual(plainText, encrypted);
            Assert.Equal(plainText, decrypted);
        }
Example #2
0
 /// <summary>
 /// 校验ticket
 /// </summary>
 /// <param name="encryptStr"></param>
 /// <returns></returns>
 public static UserInfo VerifyTicket(string encryptStr, out string client)
 {
     try
     {
         RedisHelper redisHelper = new RedisHelper("127.0.0.1:6379");
         //加密原型:guid&client; 如:08e80f78-95ad-427c-b506-a5f1504e29ac&ios
         string randomKey  = encryptStr.Substring(encryptStr.Length - 15);
         var    base64     = encryptStr.Substring(0, encryptStr.Length - 15);
         var    deBase64   = Encryption.Base64Decrypt(base64);
         var    keys       = key + randomKey;
         string ticketInfo = Encryption.DesDecrypt(deBase64, keys);
         var    guid       = ticketInfo.Split("&")[0];
         client = ticketInfo.Split("&")[1];
         string redisKey = "ticket_" + guid;
         var    obj      = redisHelper.Get <UserInfo>(redisKey);
         return(obj);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }