Esempio n. 1
0
        protected override byte[] GetResponseData(object value)
        {
            string s    = JsonConvert.SerializeObject(value);
            string str2 = Convert.ToBase64String(AESHelper.EncryptBytes(Encoding.UTF8.GetBytes(s), base._aesKey, base._aesIv));

            return(Encoding.UTF8.GetBytes(str2));
        }
Esempio n. 2
0
        internal static string EncryptToken(TokenInfo tokenInfo)
        {
            var tokenBytes = BitConverter.GetBytes(tokenInfo.AccessTime.ToBinary())
                             .Concat(Encoding.UTF8.GetBytes(tokenInfo.RefUserCode))
                             .ToArray();

            return(AESHelper.EncryptBytes(tokenBytes, _aes_key_token, _aes_iv_token).BinaryToHex());
        }
        protected virtual byte[] GetResponseData(object value)
        {
            string s = JsonConvert.SerializeObject(value);

            return(AESHelper.EncryptBytes(Encoding.UTF8.GetBytes(s), this._aesKey, this._aesIv));
        }
Esempio n. 4
0
        internal static string Encrypt(string imei, string url, string userAgent, double lng, double lat)
        {
            url       = url.ToLower().Trim();
            userAgent = userAgent.ToLower().Trim();
            int      num  = (int)(lng * 10000000.0);
            int      num2 = (int)(lat * 10000000.0);
            string   str  = string.Format("{0}{1}{2}", url, num, num2);
            string   str2 = string.Format("{0}{1}{2}", userAgent, num, num2);
            int      num3 = Math.Abs(GetHashCode2(str));
            int      num4 = Math.Abs(GetHashCode2(str2));
            DateTime time = _init_time.AddSeconds((double)-num3);
            TimeSpan span = (TimeSpan)(DateTime.Now - time);
            long     totalMilliseconds = (long)span.TotalMilliseconds;

            byte[] buffer  = LongToByteArray(totalMilliseconds, true);
            byte[] buffer2 = imei.HexToBinary();
            int    length  = buffer2.Length;
            int    key     = num3 % length;

            byte[] buffer3 = new byte[] { buffer[0], buffer[1], buffer[2] };
            KeyValuePair <int, byte[]> pair = new KeyValuePair <int, byte[]>(key, buffer3);
            int num8 = num4 % length;

            byte[] buffer4 = new byte[] { buffer[3], buffer[4], buffer[5] };
            KeyValuePair <int, byte[]> pair2 = new KeyValuePair <int, byte[]>(num8, buffer4);
            int num9 = 2;

            byte[] bytes = new byte[length + 6];
            KeyValuePair <int, byte[]>[] pairArray = new KeyValuePair <int, byte[]> [num9];
            if (key <= num8)
            {
                pairArray[0] = pair;
                pairArray[1] = pair2;
            }
            else
            {
                pairArray[0] = pair2;
                pairArray[1] = pair;
            }
            int index = 0;
            int num11 = 0;

            for (int i = 0; i < num9; i++)
            {
                int    num13   = pairArray[i].Key;
                byte[] buffer6 = pairArray[i].Value;
                int    num14   = num13 - num11;
                if (num14 != 0)
                {
                    for (int m = 0; m < num14; m++)
                    {
                        bytes[index] = buffer2[num11];
                        num11++;
                        index++;
                    }
                }
                for (int k = 0; k < buffer6.Length; k++)
                {
                    bytes[index] = buffer6[k];
                    index++;
                }
            }
            int num17 = length - num11;

            for (int j = 0; j < num17; j++)
            {
                bytes[index] = buffer2[num11];
                num11++;
                index++;
            }
            return(AESHelper.EncryptBytes(bytes, _aes_key, _aes_iv).BinaryToHex());
        }
Esempio n. 5
0
 internal static string EncryptToken(long userCode, DateTime authTime)
 {
     return(AESHelper.EncryptBytes(BitConverter.GetBytes(userCode).Concat <byte>(BitConverter.GetBytes(authTime.ToBinary())).ToArray <byte>(), AuthSettings._aes_key_token, AuthSettings._aes_iv_token).BinaryToHex());
 }