| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- using System.Diagnostics;
- using System.IO;
- using System.Text;
- using System.Security.Cryptography;
- using System;
- public static class FairGuard{
- private static bool isInitialized = false;
- private const string version = "7.1.6";
- private const string strUUU_0 = "Ce90DysQNIJUCHKmRNU3D5iWaTALey+dzOzyfv8CUnjUI06FmqEiozthUnmjKuHM2xULzwMWetEtieUBfjKNvQ==";
- private const string strHHH_0 = "8WXEpyGHQhkngJnHyBoGS4boUvmc4UFlZxs/auPu58qy7/WHv2CfVz6O9bfL+rpivAB7z4hIILTgz4nwtHLIGw==";
- private const string strIII_0 = "e6WqwzKWyswU8joVaNYOnA==";
- private const string strSSS_0 = "5OXMqsdS0ZtPf7WWtwlgB6e7yFUhXSVdytweVgUEXsA=";
- private const string strXXX_0 = "5OXMqsdS0ZtPf7WWtwlgB+QOgX9ubkaYohDeyjjyBg0=";
- private const string strGGG_0 = "beI2N5JQWRyEY5Lar9eMsFvzJtrK0L+UafGyP1zk3vo=";
- private const string strNNN_0 = "UxJvtb7ND3kpYAUPpmwhtQ==";
- private const string strRRR_0 = "LHSIOoMn0jmrAPNRyN4BkmWFUk5S6PF2NynQ+o3kMUI=";//getUltraSign
- private static string strUUU = "";
- private static string strHHH = "";
- private static string strIII = "";
- private static string strSSS = "";
- private static string strXXX = "";
- private static string strGGG = "";
- private static string strNNN = "";
- private static string strRRR = "";
- private static AndroidJavaClass g_SWPClass = null;
- public static string Decrypt(string cipherText)
- {
- string EncryptionKey = "f7f8edd10906b53544";
- cipherText = cipherText.Replace(" ", "+");
- byte[] cipherBytes = Convert.FromBase64String(cipherText);
- using (Aes encryptor = Aes.Create())
- {
- Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0xf6, 0x92, 0x90, 0x8c, 0x7f, 0x23, 0x4f, 0xc9, 0x13, 0x2d, 0x56, 0x3d, 0x66 });
- encryptor.Key = pdb.GetBytes(32);
- encryptor.IV = pdb.GetBytes(16);
- using (MemoryStream ms = new MemoryStream())
- {
- using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write))
- {
- cs.Write(cipherBytes, 0, cipherBytes.Length);
- cs.Close();
- }
- cipherText = Encoding.Unicode.GetString(ms.ToArray());
- }
- }
- return cipherText;
- }
- public static void Init()
- {
- if (isInitialized)
- {
- return;
- }
- #if UNITY_ANDROID
- strUUU = Decrypt (strUUU_0);
- strHHH = Decrypt (strHHH_0);
- strIII = Decrypt (strIII_0);
- strSSS = Decrypt (strSSS_0);
- strXXX = Decrypt (strXXX_0);
- strGGG = Decrypt (strGGG_0);
- strNNN = Decrypt (strNNN_0);
- strRRR = Decrypt (strRRR_0);
- try
- {
- using (var actClass = new AndroidJavaClass(strUUU))
- {
- g_SWPClass = new AndroidJavaClass(strHHH);
- }
- }
- catch (System.Exception e)
- {
- System.Console.Write(" " + e.ToString());
- }
- initSDK("");
- #endif
- isInitialized = true;
- }
- private static void initSDK(string gameKey)
- {
- #if UNITY_ANDROID
- if (g_SWPClass != null)
- {
- g_SWPClass.CallStatic(strIII, gameKey);
- }
- #endif
- }
- #if UNITY_IPHONE && !UNITY_EDITOR
- [DllImport ("__Internal")]
- public static extern void setUserInfo(string roleName, string roleAccount,string roleId);
- #else
- public static void setUserInfo(string roleName, string roleAccount,string roleId)
- {
- #if UNITY_ANDROID
- if (g_SWPClass != null)
- {
- g_SWPClass.CallStatic(strSSS, roleName, roleAccount, roleId);
- }
- #endif
- }
- #endif
- #if UNITY_IPHONE && !UNITY_EDITOR
- [DllImport ("__Internal")]
- public static extern void setUserInfoEx(string roleName, string roleAccount,string roleId, String serverName, String channelName, string gameJson);
- #else
- public static void setUserInfoEx(string roleName, string roleAccount,string roleId, String serverName, String channelName, string gameJson)
- {
- #if UNITY_ANDROID
- if (g_SWPClass != null)
- {
- g_SWPClass.CallStatic(strXXX, roleName, roleAccount, roleId, serverName, channelName, gameJson);
- }
- #endif
- }
- #endif
- #if UNITY_IPHONE && !UNITY_EDITOR
- [DllImport ("__Internal")]
- public static extern string setGuardId(int guardId);
- #else
- public static string setGuardId(int guardId)
- {
- string strRet="";
- #if UNITY_ANDROID
- if(g_SWPClass!=null)
- {
- strRet = g_SWPClass.CallStatic<string>(strGGG, guardId);
- }
- #endif
- return strRet;
- }
- #endif
- public static string getSign(String inputData)
- {
- string strRet = "";
- #if UNITY_ANDROID
- if (g_SWPClass != null)
- {
- strRet = g_SWPClass.CallStatic<string>(strNNN, inputData);
- }
- #endif
- return strRet;
- }
- public static string getUltraSign(String inputData)
- {
- string strRet = "";
- #if UNITY_ANDROID
- if (g_SWPClass != null)
- {
- strRet = g_SWPClass.CallStatic<string>(strRRR, inputData);
- }
- #endif
- return strRet;
- }
- }
|