Example #1
0
        public static GameRuntimeData LoadArchive(int fileIndex)
        {
            string          sPath      = GetArchiveFilePath(fileIndex);
            GameRuntimeData tagArchive = null;

            if (File.Exists(sPath))
            {
                using (FileStream fs = File.OpenRead(sPath))
                {
                    byte[] buffer1 = new byte[sizeof(int)];
                    fs.Read(buffer1, 0, sizeof(int));
                    int    dataLen     = BitConverter.ToInt32(buffer1, 0);
                    byte[] archiveData = new byte[dataLen];
                    fs.Read(archiveData, 0, dataLen);

                    TDES tdesTool = new TDES();
                    tdesTool.Init(ConStr.DES_KEY);

                    byte[]    decryptData = tdesTool.Decrypt(archiveData);
                    string    txtData     = System.Text.Encoding.Default.GetString(decryptData, 0, decryptData.Length);
                    Hashtable hsData      = txtData.hashtableFromJson();
                    tagArchive = Saveable.Facade.LoadRoot <GameRuntimeData>(hsData);

                    fs.Close();
                }
            }
            _instance           = tagArchive;//记录单例
            _instance.SaveIndex = fileIndex;
            _instance.InitAllRole();
            return(tagArchive);
        }
Example #2
0
        public void MessageReceived(string json)
        {
            if (asymkey != null)
            {
                json = RSA.Decrypt(asymkey, json);
            }
            else
            if (symkey != null)
            {
                json = TDES.Decrypt(symkey, json);
            }
            JSONObject jo = new JSONObject(json);

            callback?.Invoke(this, jo);
        }
Example #3
0
 public static string Decrypt(Algorithm algorithm, string symmetricKey, string token, string content)
 {
     if (algorithm == Algorithm.AES)
     {
         content = AES.Decrypt(symmetricKey, content, token);
     }
     else if (algorithm == Algorithm.RIJ)
     {
         content = RIJ.Decrypt(symmetricKey, content, token);
     }
     else if (algorithm == Algorithm.DES)
     {
         content = TDES.Decrypt(symmetricKey, content, token);
     }
     else
     {
         content = string.Empty;
     }
     return(content);
 }