internal static TokenInfo DecryptToken(string token) { var tokenBin = token.HexToBinary(); tokenBin = AESHelper.DecryptBytes(tokenBin, _aes_key_token, _aes_iv_token); return(new TokenInfo { RefUserCode = Encoding.UTF8.GetString(tokenBin, 0, tokenBin.Length - 8), AccessTime = DateTime.FromBinary(BitConverter.ToInt64(tokenBin, tokenBin.Length - 8)), }); }
internal static TokenInfo DecryptToken(string token) { byte[] buffer = AESHelper.DecryptBytes(token.HexToBinary(), AuthSettings._aes_key_token, AuthSettings._aes_iv_token); if (buffer.Length == 12) { return(new TokenInfo { UserCode = BitConverter.ToInt32(buffer, 0), AuthTime = DateTime.FromBinary(BitConverter.ToInt64(buffer, 4)) }); } return(new TokenInfo { UserCode = BitConverter.ToInt64(buffer, 0), AuthTime = DateTime.FromBinary(BitConverter.ToInt64(buffer, 8)) }); }
internal static RequestImeiDto Decrypt(string encryptedImei, string url, string userAgent, double lng, double lat) { RequestImeiDto dto = new RequestImeiDto(encryptedImei); try { if (string.IsNullOrEmpty(encryptedImei)) { dto.IsFake = true; return(dto); } byte[] src = null; src = AESHelper.DecryptBytes(encryptedImei.HexToBinary(), _aes_key, _aes_iv); url = (url == null) ? "" : url.ToLower().Trim(); userAgent = (userAgent == null) ? "" : 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); int length = src.Length; int num6 = length - 6; int key = num3 % num6; int num8 = num4 % num6; int num9 = 2; byte[] dst = new byte[8]; byte[] buffer3 = new byte[num6]; KeyValuePair <int, int>[] pairArray = new KeyValuePair <int, int> [2]; if (key <= num8) { pairArray[0] = new KeyValuePair <int, int>(key, 0); pairArray[1] = new KeyValuePair <int, int>(num8, 1); } else { pairArray[0] = new KeyValuePair <int, int>(num8, 1); pairArray[1] = new KeyValuePair <int, int>(key, 0); } int srcOffset = 0; int dstOffset = 0; for (int i = 0; i < num9; i++) { int num13 = pairArray[i].Key + (i * 3); int num14 = pairArray[i].Value; int num15 = num13 - srcOffset; if (num15 != 0) { Buffer.BlockCopy(src, srcOffset, buffer3, dstOffset, num15); dstOffset += num15; srcOffset += num15; } Buffer.BlockCopy(src, num13, dst, num14 * 3, 3); srcOffset += 3; } int count = length - srcOffset; if (count != 0) { Buffer.BlockCopy(src, srcOffset, buffer3, dstOffset, count); } long num17 = BitConverter.ToInt64(dst, 0); dto.GenerateTime = new DateTime?(time.AddMilliseconds((double)num17).ToLocalTime()); dto.RealImei = buffer3.BinaryToHex(); dto.IsFake = false; return(dto); } catch { dto.IsFake = true; return(dto); } }