Commit 0bc4b92e authored by 王雪伟's avatar 王雪伟

加入umeng上报的的判空 解密数据的解析

parent 269f2a58
...@@ -30,7 +30,7 @@ public class GDTRewardAdUtil ...@@ -30,7 +30,7 @@ public class GDTRewardAdUtil
{ {
RewardVideoAd rewardVideoAd = new RewardVideoAd(entity.codeId); RewardVideoAd rewardVideoAd = new RewardVideoAd(entity.codeId);
rewardVideoAd.SetListener(new RewardVideoAdListener(this, entity, rewardVideoAd, callback, true)); rewardVideoAd.SetListener(new RewardVideoAdListener(this, entity, rewardVideoAd, callback, true));
rewardVideoAd.SetVideoMuted(true);//设置声音 rewardVideoAd.SetVideoMuted(false);//设置声音
rewardVideoAd.LoadAd(); rewardVideoAd.LoadAd();
} }
...@@ -50,7 +50,7 @@ public class GDTRewardAdUtil ...@@ -50,7 +50,7 @@ public class GDTRewardAdUtil
#if UNITY_IOS #if UNITY_IOS
rewardAd.SetEnableDefaultAudioSessionSetting(false); rewardAd.SetEnableDefaultAudioSessionSetting(false);
#endif #endif
rewardAd.SetVideoMuted(true);//设置是否打开声音 rewardAd.SetVideoMuted(false);//设置是否打开声音
rewardAd.ShowAD(); rewardAd.ShowAD();
} }
else else
......
...@@ -1341,7 +1341,7 @@ MonoBehaviour: ...@@ -1341,7 +1341,7 @@ MonoBehaviour:
m_PersistentCalls: m_PersistentCalls:
m_Calls: m_Calls:
- m_Target: {fileID: 329210704} - m_Target: {fileID: 329210704}
m_MethodName: TestJiami m_MethodName: OnClickTestSign
m_Mode: 1 m_Mode: 1
m_Arguments: m_Arguments:
m_ObjectArgument: {fileID: 0} m_ObjectArgument: {fileID: 0}
......
using System; using LitJson;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using UnityEngine; using UnityEngine;
using UnityEngine.Android; using UnityEngine.Android;
using UnityEngine.UI; using UnityEngine.UI;
...@@ -25,7 +27,7 @@ public class HttpTest : MonoBehaviour ...@@ -25,7 +27,7 @@ public class HttpTest : MonoBehaviour
//app/v1/game/xynt/home_info //app/v1/game/xynt/home_info
HttpTool.Instance._Get("app/v1/game/xynt/land_list", null, new Action<List<TestBean>>((bean) => HttpTool.Instance._Get("app/v1/game/xynt/land_list", null, new Action<List<TestBean>>((bean) =>
{ {
Debug.Log("Get 请求成功"+ bean.Count); Debug.Log("Get 请求成功" + bean.Count);
}), new Action<string, string>((code, errMsg) => }), new Action<string, string>((code, errMsg) =>
{ {
...@@ -115,7 +117,32 @@ public class HttpTest : MonoBehaviour ...@@ -115,7 +117,32 @@ public class HttpTest : MonoBehaviour
{ {
})); }));
}
//string enc = "cYMqfCFXX1qTbOitQJVqOtUsXx/8ZeTXIjnsq9MpqMXkx+v92z5wAWjM5l+RPAHjih2CmDKTljKPuY4DaAQ2FxUXl05hUN0Kc84g0WOZFEDeVsQ2UB/Dhp6KTtSlVGVPlQ1hWZpkEq3ZhE4H2EY2KVKNYW0B9rlRyOYGLCumeGMsMXR1Vnz+l8MLXSshdzBh6ZqksdPYeU1qk3FuXWN71Y54kM8JIun7DW5uL2EVxjYVgvbcgtMxWdIBQxlbE0wQWDwQ3XnPn8j7nQ/v+TB9r3q10k837ZfkO+t5UpSCIQwZFA7/ZUyf9t/HJoklRJGDmtL+ua5F4xTi+amBdlCkmlnnr4PNqgpnP/AojVCkpDfhoO96CH/H9tbkoyrt2fueCTjHfoQYV/HKV0RrvYTG789JUGn2/brzL2MWSv0EkFYNihTGPzifG9C1gvSyIH/wkghFNl7zeOUzWalKw3NFRj1bLyjDy8oHjnGsMbQA4iZZKPz/YUZekXrNY/KAFuVQYHXLsMVLn2vYLg+It/TkDDyxOUI+OUGClqpWwZ64QMTwIk0BEjdmQTmnlIiQNDYNEe4Ghi5cQ0kpjA1/EUHk2CA7tHkqaUsYA7/8DzgG9QJIk0PRcjXViWzw8cndJ+fn0F9pxa9JtCblupwAxqToWdlGK5z7e5Tu0vYo5QQTa1f2VdC1ndlA9tdwFkYGpumQaJA3v04OgWqbp6mBdC460ctVa+kvFeh3/V0KrnhYtiryen/lm63gAen2wc66M4LgCOB27Exz6Cbcj5HYkpHI66tDOAq87Kke9LaHUFgfxG6sqocSSso+ngRFBAmggIp5eo4vI7KiUa1YNeEKqv8181BF2FzkHtYeA7127GsSD/f7UacLm78HhM/tBeBhptnXkwoqicjeL8vOYMSnG1X3wINvtVYPS/bPesxO693vmAIYrDlLd0s6dyUHdB5BQL5zeG7wsgYe9lyM/FclqvT23gcar+ukA1ObUzrcoqOYkmTQMu7J7TxxWl+Zrv1abU+p4nMJ0QVOb+1s066VIVyGbY/Ayz0ihdpWKsjSy8jb9VxvjcbNfz6F8p3OLnFr9LTR63f7kHrUFLgInX1azqYGm6TtgDFttVi/6iSgGvP6c3NILwJH0ckbhOqKy7NX7pX03c7kCXxOgME+5khbT1KfOca7INZxhku6ZAVRjSqrusItcvTHkIxfNuDyN7kaVSP5wmWKZB9vbpxnM1F9K8LQezHapJ1fFNm51CiMucIZTJtLkXo1Qr9hmplKIu3TnZ0csG+wuUDToo12VrG6/WIVmv8gshf6Xbunxah/GK52c6GQfAKQmTGCJufwXWHMIkyoLHbhvWDZ+1jMT7UUcwOoM4vL7OXHAxafBAZ5JbVEL26S7sJzs/V30OcH6fpaXHc3F7s/xABOzzF0iiuO1DtZv5jib8sWHizIEXsgenbkQHfNo+y77z0k/HUmIrybKNMqgOzDRp3d2ttSzaT2e+oSrt7LJFXitvMuRxGKA/rwowagqOkO/cqSrAIqRXpp4j33AmmtvS5vm0fj3eDVpAhP8/ZCcEDVEWFKRPZYGIY7EbYuV4o3ixNihsLoDK7qLVYx/xXi8kRBUpyu5+Q3dRDjkJWMIaYt65rmLJj3encjx7x9KrVWgWiApgjkclcqezqd5CuoAZFAAneTo+FH+1jgz0Y+9DIEj9eEynTAqyUSZH4=";
public void OnClickTestSign()
{
//String signResult = EncryptHelper.EncryptHelper.DeCode(response.enc, "as09384io03lmp78", "e2e7d664d72f710c");
//try
//{
// //String signResult = DataSignVerify(response.enc, response.sign);
// Debug.unityLogger.Log("DecryptInterceptor", "signResult: " + signResult);
// if (("OK").Equals(signResult))
// {
// //String decryptResult = DecryptData(response.enc);
// //Debug.unityLogger.Log("DecryptInterceptor", "decryptResult: " + decryptResult);
// }
// else
// {
// Debug.unityLogger.Log("DecryptInterceptor", "decryptResult: error");
// }
//}
//catch (Exception e)
//{
// Debug.unityLogger.Log("DecryptInterceptor", "error"+e.ToString());
//}
} }
......
...@@ -3,6 +3,7 @@ using System.IO; ...@@ -3,6 +3,7 @@ using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using UnityEngine;
namespace EncryptHelper namespace EncryptHelper
{ {
...@@ -125,6 +126,126 @@ namespace EncryptHelper ...@@ -125,6 +126,126 @@ namespace EncryptHelper
} }
} }
} }
/// <summary>
/// 加密数据
/// </summary>
/// <param name="data">明文数据</param>
/// <param name="key">密钥</param>
/// <param name="iv">偏移</param>
/// <returns></returns>
public static string EnCode(string data, string key, string iv)
{
try
{
byte[] keyArray = Encoding.UTF8.GetBytes(key);
byte[] ivArray = Encoding.UTF8.GetBytes(iv);
byte[] toEncryptArray = Encoding.UTF8.GetBytes(data);
RijndaelManaged rDel = new RijndaelManaged();
rDel.Key = keyArray;
rDel.IV = ivArray;
rDel.Mode = CipherMode.CBC;
rDel.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = rDel.CreateEncryptor();
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
return Convert.ToBase64String(resultArray, 0, resultArray.Length);
}
catch (Exception e)
{
return "";
}
}
/// <summary>
/// 解密数据
/// </summary>
/// <param name="data">加密内容</param>
/// <param name="key">密钥</param>
/// <param name="iv">偏移</param>
/// <returns></returns>
public static string DeCode(string data, string key, string iv)
{
try
{
byte[] keyArray = Encoding.UTF8.GetBytes(key);
byte[] ivArray = Encoding.UTF8.GetBytes(iv);
byte[] toEncryptArray = Convert.FromBase64String(data);
RijndaelManaged rDel = new RijndaelManaged();
rDel.Key = keyArray;
rDel.IV = ivArray;
rDel.Mode = CipherMode.CBC;
rDel.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = rDel.CreateDecryptor();
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
return Encoding.UTF8.GetString(resultArray);
}
catch (Exception e)
{
return "";
}
}
/// <summary>
/// AES解密
/// </summary>
/// <param name="Data">被解密的密文</param>
/// <param name="Key">密钥</param>
/// <param name="Vector">向量</param>
/// <returns>明文</returns>
public static String AESDecrypt(String Data, String Key, String Vector)
{
//string dummyData = Data.Trim().Replace("%", "").Replace(",", "").Replace(" ", "+");
//if (dummyData.Length % 4 > 0)
//{
// dummyData = dummyData.PadRight(dummyData.Length + 4 - dummyData.Length % 4, '=');
//}
Byte[] encryptedBytes = Convert.FromBase64String(Data);
Byte[] bKey = new Byte[32];
Array.Copy(Encoding.UTF8.GetBytes(Key.PadRight(bKey.Length)), bKey, bKey.Length);
Byte[] bVector = new Byte[16];
Array.Copy(Encoding.UTF8.GetBytes(Vector.PadRight(bVector.Length)), bVector, bVector.Length);
Byte[] original = null; // 解密后的明文
Rijndael Aes = Rijndael.Create();
try
{
// 开辟一块内存流,存储密文
using (MemoryStream Memory = new MemoryStream(encryptedBytes))
{
// 把内存流对象包装成加密流对象
using (CryptoStream Decryptor = new CryptoStream(Memory,
Aes.CreateDecryptor(bKey, bVector),
CryptoStreamMode.Read))
{
// 明文存储区
using (MemoryStream originalMemory = new MemoryStream())
{
Byte[] Buffer = new Byte[1024];
Int32 readBytes = 0;
while ((readBytes = Decryptor.Read(Buffer, 0, Buffer.Length)) > 0)
{
originalMemory.Write(Buffer, 0, readBytes);
}
original = originalMemory.ToArray();
}
}
}
}
catch(Exception e)
{
original = null;
}
return Encoding.UTF8.GetString(original);
}
/// <summary> /// <summary>
/// MD5加密 /// MD5加密
/// </summary> /// </summary>
......
...@@ -126,7 +126,7 @@ public class HttpTool : MonoBehaviour ...@@ -126,7 +126,7 @@ public class HttpTool : MonoBehaviour
public IEnumerator PostRequestReport(string jsonString) public IEnumerator PostRequestReport(string jsonString)
{ {
string url = BaseEventUrl + "logCollection/log/v1/userLogCollection?module=behavior"+addParams(null); string url = BaseEventUrl + "logCollection/log/v1/userLogCollection?module=behavior&" + addParams(null);
using (UnityWebRequest webRequest = UnityWebRequest.Post (url, "")) using (UnityWebRequest webRequest = UnityWebRequest.Post (url, ""))
{ {
if (jsonString != null && jsonString.Length > 0) if (jsonString != null && jsonString.Length > 0)
...@@ -282,7 +282,16 @@ public class HttpTool : MonoBehaviour ...@@ -282,7 +282,16 @@ public class HttpTool : MonoBehaviour
Response<T> response = JsonMapper.ToObject<Response<T>>(json); Response<T> response = JsonMapper.ToObject<Response<T>>(json);
if (response.status == 200) if (response.status == 200)
{ {
success(response.result.data); if (response.security.Equals("SECURITY"))
{
string signResult = EncryptHelper.EncryptHelper.DeCode(response.enc, "as09384io03lmp78", "e2e7d664d72f710c");
success(JsonMapper.ToObject<T>(signResult));
}
else
{
success(response.result.data);
}
} }
else else
{ {
......
...@@ -6,6 +6,9 @@ public class Response<T> ...@@ -6,6 +6,9 @@ public class Response<T>
public int status; public int status;
public string msg = ""; public string msg = "";
public Result<T> result = null; public Result<T> result = null;
public string sign = "";
public string enc = "";
public string security = "";
[Serializable] [Serializable]
public class Result<T> public class Result<T>
......
...@@ -22,7 +22,7 @@ public final class UnionApplication extends Application { ...@@ -22,7 +22,7 @@ public final class UnionApplication extends Application {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
AppliContext.init(this); AppliContext.init(this);
UMConfigure.setLogEnabled(true);
UMConfigure.init(this, "602f890b668f9e17b8b31413", "xynt", UMConfigure.DEVICE_TYPE_PHONE,""); UMConfigure.init(this, "602f890b668f9e17b8b31413", "xynt", UMConfigure.DEVICE_TYPE_PHONE,"");
// TTAdConfig config = new TTAdConfig.Builder() // TTAdConfig config = new TTAdConfig.Builder()
// //.appId("5001121") // //.appId("5001121")
......
using Umeng; using Umeng;
using LitJson; using LitJson;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine;
public class EventUtils public class EventUtils
{ {
...@@ -17,6 +18,7 @@ public class EventUtils ...@@ -17,6 +18,7 @@ public class EventUtils
map["event"] = Event; map["event"] = Event;
map["action"] = action; map["action"] = action;
HttpTool.Instance._PostEvent(JsonMapper.ToJson(map)); HttpTool.Instance._PostEvent(JsonMapper.ToJson(map));
Debug.unityLogger.Log("UmLog", "OnEvent action" + action);
GA.Event(action); GA.Event(action);
} }
public static void OnEvent(string action, string value) public static void OnEvent(string action, string value)
...@@ -26,6 +28,7 @@ public class EventUtils ...@@ -26,6 +28,7 @@ public class EventUtils
map["action"] = action; map["action"] = action;
map["value"] = value; map["value"] = value;
HttpTool.Instance._PostEvent(JsonMapper.ToJson(map)); HttpTool.Instance._PostEvent(JsonMapper.ToJson(map));
Debug.unityLogger.Log("UmLog", "OnEvent action" + action+ " value " + value);
GA.Event(action, value); GA.Event(action, value);
} }
...@@ -43,7 +46,7 @@ public class EventUtils ...@@ -43,7 +46,7 @@ public class EventUtils
} }
if (entity.actionName == null) if (entity.actionName == null)
{ {
entity.actionName = ""; entity.actionName = entity.slotName+ "PullFail";
} }
Dictionary<string, string> map = new Dictionary<string, string>(); Dictionary<string, string> map = new Dictionary<string, string>();
map["event"] = Event; map["event"] = Event;
...@@ -61,7 +64,8 @@ public class EventUtils ...@@ -61,7 +64,8 @@ public class EventUtils
{ {
HttpTool.Instance._GetEvent(entity.pullfail_tracking[0]); HttpTool.Instance._GetEvent(entity.pullfail_tracking[0]);
} }
GA.Event(entity.actionName); Debug.unityLogger.Log("UmLog", "onEventPullFail entity.actionName " + entity.actionName);
GA.Event(entity.actionName);
} }
/// <summary> /// <summary>
...@@ -76,7 +80,7 @@ public class EventUtils ...@@ -76,7 +80,7 @@ public class EventUtils
} }
if (entity.actionName == null) if (entity.actionName == null)
{ {
entity.actionName = ""; entity.actionName = entity.slotName + "PullSuc";
} }
Dictionary<string, string> map = new Dictionary<string, string>(); Dictionary<string, string> map = new Dictionary<string, string>();
map["event"] = Event; map["event"] = Event;
...@@ -91,6 +95,7 @@ public class EventUtils ...@@ -91,6 +95,7 @@ public class EventUtils
{ {
HttpTool.Instance._GetEvent(entity.pullsucc_tracking[0]); HttpTool.Instance._GetEvent(entity.pullsucc_tracking[0]);
} }
Debug.unityLogger.Log("UmLog", "onEventPullSuccess entity.actionName " + entity.actionName);
GA.Event(entity.actionName); GA.Event(entity.actionName);
} }
/// <summary> /// <summary>
...@@ -104,7 +109,7 @@ public class EventUtils ...@@ -104,7 +109,7 @@ public class EventUtils
} }
if (entity.actionName == null) if (entity.actionName == null)
{ {
entity.actionName = ""; entity.actionName = entity.slotName + "PullSuc";
} }
Dictionary<string, string> map = new Dictionary<string, string>(); Dictionary<string, string> map = new Dictionary<string, string>();
map["event"] = Event; map["event"] = Event;
...@@ -133,7 +138,7 @@ public class EventUtils ...@@ -133,7 +138,7 @@ public class EventUtils
} }
if (entity.actionName == null) if (entity.actionName == null)
{ {
entity.actionName = ""; entity.actionName = entity.slotName + "ShowFail";
} }
Dictionary<string, string> map = new Dictionary<string, string>(); Dictionary<string, string> map = new Dictionary<string, string>();
map["event"] = Event; map["event"] = Event;
...@@ -148,6 +153,7 @@ public class EventUtils ...@@ -148,6 +153,7 @@ public class EventUtils
{ {
HttpTool.Instance._GetEvent(entity.showfail_tracking[0]); HttpTool.Instance._GetEvent(entity.showfail_tracking[0]);
} }
Debug.unityLogger.Log("UmLog", "onEventShowFail entity.actionName " + entity.actionName);
GA.Event(entity.actionName); GA.Event(entity.actionName);
} }
/// <summary> /// <summary>
...@@ -162,7 +168,7 @@ public class EventUtils ...@@ -162,7 +168,7 @@ public class EventUtils
} }
if (entity.actionName == null) if (entity.actionName == null)
{ {
entity.actionName = ""; entity.actionName = entity.slotName + "Complete";
} }
Dictionary<string, string> map = new Dictionary<string, string>(); Dictionary<string, string> map = new Dictionary<string, string>();
map["event"] = Event; map["event"] = Event;
...@@ -177,6 +183,7 @@ public class EventUtils ...@@ -177,6 +183,7 @@ public class EventUtils
{ {
HttpTool.Instance._GetEvent(entity.playcomplete_trackings[0]); HttpTool.Instance._GetEvent(entity.playcomplete_trackings[0]);
} }
Debug.unityLogger.Log("UmLog", "onEventAdComplete entity.actionName " + entity.actionName);
GA.Event(entity.actionName); GA.Event(entity.actionName);
} }
...@@ -192,7 +199,7 @@ public class EventUtils ...@@ -192,7 +199,7 @@ public class EventUtils
} }
if (entity.actionName == null) if (entity.actionName == null)
{ {
entity.actionName = ""; entity.actionName = entity.slotName + "Click";
} }
Dictionary<string, string> map = new Dictionary<string, string>(); Dictionary<string, string> map = new Dictionary<string, string>();
map["event"] = Event; map["event"] = Event;
...@@ -207,6 +214,7 @@ public class EventUtils ...@@ -207,6 +214,7 @@ public class EventUtils
{ {
HttpTool.Instance._GetEvent(entity.clk_tracking[0]); HttpTool.Instance._GetEvent(entity.clk_tracking[0]);
} }
Debug.unityLogger.Log("UmLog", "onEventAdClick entity.actionName " + entity.actionName);
GA.Event(entity.actionName); GA.Event(entity.actionName);
} }
......
...@@ -11,13 +11,13 @@ EditorBuildSettings: ...@@ -11,13 +11,13 @@ EditorBuildSettings:
- enabled: 0 - enabled: 0
path: Assets/AD/GDT/UnionDemo/UnionExample.unity path: Assets/AD/GDT/UnionDemo/UnionExample.unity
guid: 6c963ae210fa3c3438c2f6770ee81fc9 guid: 6c963ae210fa3c3438c2f6770ee81fc9
- enabled: 1 - enabled: 0
path: Assets/Game/Splash/Splash.unity path: Assets/Game/Splash/Splash.unity
guid: 37af8cf3fb373478ab04e3ee2f3b700a guid: 37af8cf3fb373478ab04e3ee2f3b700a
- enabled: 1 - enabled: 0
path: Assets/AD/Demo/AdDemo.unity path: Assets/AD/Demo/AdDemo.unity
guid: ef80a35d44f809e4a8957d1ed9571fd2 guid: ef80a35d44f809e4a8957d1ed9571fd2
- enabled: 0 - enabled: 1
path: Assets/NetWork/Demo/HttpDemo.unity path: Assets/NetWork/Demo/HttpDemo.unity
guid: 1d254830c8b62484bb74d303cbb2cc3d guid: 1d254830c8b62484bb74d303cbb2cc3d
m_configObjects: {} m_configObjects: {}
...@@ -270,7 +270,7 @@ PlayerSettings: ...@@ -270,7 +270,7 @@ PlayerSettings:
AndroidEnableTango: 0 AndroidEnableTango: 0
androidEnableBanner: 1 androidEnableBanner: 1
androidUseLowAccuracyLocation: 0 androidUseLowAccuracyLocation: 0
androidUseCustomKeystore: 1 androidUseCustomKeystore: 0
m_AndroidBanners: m_AndroidBanners:
- width: 320 - width: 320
height: 180 height: 180
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment