using System; using System.Collections.Generic; using System.Security.Cryptography; namespace SogClient { /// /// 游客账号加密模块 /// public static class GuestCrypto { enum PLATFORM { ANDROID = 1, IOS = 2, WINDOWS = 3, } public static string GetAccountId(string deviceId) { return deviceId + "@" + getPlatform(); } public static string GetAccountToken(string accountId) { SHA1 sha1 = new SHA1CryptoServiceProvider(); byte[] dataIn = System.Text.Encoding.UTF8.GetBytes(accountId + "-xGame"); byte[] dataOut = sha1.ComputeHash(dataIn); string str = BitConverter.ToString(dataOut); return str.Replace("-", ""); } public static string getPlatform(int platformType = 1) { #if UNITY_5_3 string platform = AppConst.DeviceSystem(); return Enum.Parse(typeof(PLATFORM), platform, true).ToString(); #else return Enum.GetName(typeof(PLATFORM), platformType); #endif } } }