private void PopQueueEntrance(Decipher decipher) { Interaction.TurnOffAllInteractionWindow(); ControllerManager.SyncActions = false; PopUpNotification.Push("Your queue is ready, do you want to join?", PopUpNotification.Type.Select); StartCoroutine(PopUpNotification.WaitForDecisionThenPerformAction(AcceptEntrance, DenyEntrance)); }
public void Decipher(string content, string keyPath, string filePath) { string key = File.ReadAllText(keyPath, _defaultEncoding); Decipher decipher = new Decipher(content, key); File.WriteAllText(filePath, decipher.CryptStr, _defaultEncoding); }
private void UnEquipAction(Decipher decipher) { UnEquipActionData temp = JsonUtility.FromJson <UnEquipActionData>(decipher.content); if (CacheManager.Players[temp.ClientID].PC) { CacheManager.Players[temp.ClientID].PC.UnEquip((EQUIPTYPE)temp.Slot); } }
//Flag private void EquipAction(Decipher decipher) { EquipActionData temp = JsonUtility.FromJson <EquipActionData>(decipher.content); if (CacheManager.Players[temp.ClientID].PC) { CacheManager.Players[temp.ClientID].PC.Equip(temp.E); } }
private void DisconnectByServer(Decipher decipher) { byte error; NetworkTransport.Disconnect(decipher.tail, ClientID, out error); if (decipher.content != string.Empty) { PopUpNotification.Push(decipher.content, PopUpNotification.Type.Confirm); } }
void Process() { //int HostID = 0; //int ClientID; //int rec_hostID = 0; int rec_connectionID; int rec_channelID; byte[] buffer = new byte[1024]; int buffer_length; byte error; NetworkEventType networkEvent = NetworkEventType.DataEvent; do { networkEvent = NetworkTransport.ReceiveFromHost(HostID, out rec_connectionID, out rec_channelID, buffer, 1024, out buffer_length, out error); switch (networkEvent) { case NetworkEventType.ConnectEvent: // Server received connect event Connected = true; Debug.Log("Connected."); break; case NetworkEventType.DataEvent: // Server received data try { //Try catch is super expensive, a data server will replace it later Decipher d = Serializer.UnSeal(HostID, buffer); SendMessage(d.protocol, d); } catch { AppendBuffer(buffer, buffer_length); } break; case NetworkEventType.DisconnectEvent: // Client received disconnect event Connected = false; if (error == 6) //Server down { StartCoroutine(Scene.LoadThenExecute(ID.StartMenu, PopUpNotification.Push, "Disconnected from server.", PopUpNotification.Type.Confirm)); } Debug.Log("Disconnected."); ClientID = -1; break; case NetworkEventType.BroadcastEvent: //This block should be removed for network version if (Connected || ip != String.Empty) { return; } NetworkTransport.GetBroadcastConnectionMessage(HostID, buffer, 1024, out buffer_length, out error); ip = Serializer.DeSerialize <string>(buffer); RootButtons.cg.interactable = true; break; } } while (networkEvent != NetworkEventType.Nothing); }
public static void Main(string[] args) { var jsonData = LoadEmbeddedResource("example.json"); var testKey = LoadEmbeddedResource("test-pkey.pub"); var testKeySec = LoadEmbeddedResource("test-pkey.sec"); Console.WriteLine($"Input: \n{jsonData}"); Console.WriteLine("\n\n"); var cipher = new Cipher(new List <string> { testKey }); var skipFields = new List <string> { Tools.CipherPathCombine("data", "User_viewer", "me", "avatar"), }; Console.WriteLine(skipFields[0]); var data = cipher.GenerateEncryptedPacket(JObject.Parse(jsonData), skipFields); Console.WriteLine($"Key: {data.EncryptedKey}"); Console.WriteLine(data.EncryptedJSON); Console.WriteLine("--------------------------------------------------------------------------"); var decipher = new Decipher(testKeySec); if (!decipher.Unlock("1234567890")) { Console.WriteLine("Error decrypting key!"); return; } var dec = decipher.DecipherPacket(data); Console.WriteLine($"JSON Changed: {dec.JSONChanged}"); Console.WriteLine("Changes: "); dec.UnmatchedFields.ForEach((c) => Console.WriteLine($"\t{c.Expected} => {c.Got}")); Console.WriteLine(dec.DecryptedData); Console.WriteLine("--------------------------------------------------------------------------"); data.EncryptedJSON["data"]["User_viewer"]["me"]["baseName"] = data.EncryptedJSON["data"]["User_viewer"]["me"]["id"]; var a = data.EncryptedJSON["data"]["User_viewer"]["me"]["keyAliases"][0]; var b = data.EncryptedJSON["data"]["User_viewer"]["me"]["keyAliases"][1]; data.EncryptedJSON["data"]["User_viewer"]["me"]["keyAliases"][0] = b; data.EncryptedJSON["data"]["User_viewer"]["me"]["keyAliases"][1] = a; dec = decipher.DecipherPacket(data); Console.WriteLine($"JSON Changed: {dec.JSONChanged}"); Console.WriteLine("Changes: "); dec.UnmatchedFields.ForEach((c) => Console.WriteLine($"\t{c.Expected} => {c.Got}")); Console.WriteLine(dec.DecryptedData); }
private void UpdatePlayerAttackVector(Decipher decipher) { AttackData temp = JsonUtility.FromJson <AttackData>(decipher.content); if (CacheManager.Players[temp.ClientID].PC) { CacheManager.Players[temp.ClientID].PC.AttackVector = temp.AttackVector; if (CacheManager.Players[temp.ClientID].PC == CacheManager.MP) { CacheManager.MP.ExpectingAttackVector = false; } } }
private void UpdatePlayerDirection(Decipher decipher) { DirectionData temp = JsonUtility.FromJson <DirectionData>(decipher.content); if (CacheManager.Players[temp.ClientID].PC) { CacheManager.Players[temp.ClientID].PC.Direction = temp.Direction; if (CacheManager.Players[temp.ClientID].PC == CacheManager.MP) { CacheManager.MP.ExpectingDirection = false; } } }
private void UpdatePlayerMoveVector(Decipher decipher) { MovementData temp = JsonUtility.FromJson <MovementData>(decipher.content); if (CacheManager.Players[temp.ClientID].PC) { CacheManager.Players[temp.ClientID].PC.MoveVector = temp.MoveVector; if (CacheManager.Players[temp.ClientID].PC == CacheManager.MP) { CacheManager.MP.ExpectingMoveVector = false; } } }
private void UpdatePlayerPosition(Decipher decipher) { PositionData temp = JsonUtility.FromJson <PositionData>(decipher.content); if (CacheManager.Players[temp.ClientID].PC) { //CacheManager.Players[temp.ClientID].PC.Lerps.Add(temp.Position); //CacheManager.Players[temp.ClientID].PC.Position = temp.Position; if (Mathf.Abs(Vector2.Distance(temp.Position, CacheManager.Players[temp.ClientID].PC.Position)) > 0.1f) { //CacheManager.Players[temp.ClientID].PC.Position = Vector2.Lerp(CacheManager.Players[temp.ClientID].PC.Position, temp.Position, 1f); CacheManager.Players[temp.ClientID].PC.Position = temp.Position; } } }
static void Main(string[] args) { string backslash = @"\"; var EditFileName = @"names-result.txt"; string value = Console.ReadLine(); string[] array = new string[] {}; array = value.Split(' '); var FilePath = (array[0]); //This is necessary if the user doesn't do a space after dragging a file in command prompt //Otherwise it causes an index out of exception if (array.Length == 1) { Array.Resize(ref array, array.Length + 1); array[1] = ""; } var EditedFile = (array[1]); //If the user does a space and its empty, or if whats right above happens. //This would grab the directory that the file is being used to change //the homoglyphs to normal characters. if (array[1] == "") { EditedFile = "" + Path.GetDirectoryName(FilePath); } //This is necessary if you decide to have the edited file be created in C:\ //Otherwise when placed in a folder there isn't a backslash. if (!EditedFile.EndsWith(backslash)) { EditedFile += @"\"; } using (var fixedFile = new StreamWriter($"{EditedFile}" + $"{EditFileName}")) { List <string> records = File.ReadAllLines($"{FilePath}", Encoding.GetEncoding(1252)).ToList(); Decipher name = new Decipher(); string correctFormatName = ""; foreach (string NextLine in records) { correctFormatName = name.ConvertString(NextLine); fixedFile.WriteLine(correctFormatName); } } }
//Client Protocols private void Identify(Decipher decipher) //Any instance based action required Identify self first, and this will be done by server once login { ClientID = int.Parse(decipher.content); }
private void CreateUsername(Decipher decipher) { DataManager.CreateUsernameProfile(decipher.content); PopUpNotification.Push("Successfully registered.", PopUpNotification.Type.Confirm); }
private void TopNotify(Decipher decipher) { TopNotifyData temp = JsonUtility.FromJson <TopNotifyData>(decipher.content); TopNotification.Push(temp.message, temp.color, temp.period); }
private void PopUpNotify(Decipher decipher) { PopUpNotification.Push(decipher.content, PopUpNotification.Type.Confirm); }
private void Test(Decipher decipher) { Debug.Log("Got IP"); }
private void SyncLoadedScene(Decipher decipher) { Scene.ActiveScene(1f, CacheManager.InstantiatePlayers); }
private void LoadSceneWithSync(Decipher decipher) { Scene.LoadWithManualActive(JsonUtility.FromJson <ID>(decipher.content)); }
private void LoadVillage(Decipher decipher) { CacheManager.CachePlayerData(ClientID, DataManager.UserData.PlayerDatas[CacheManager.CachedPlayerSlotIndex], ObjectIdentity.Main);//Cache Main Player Data Scene.LoadWithAction(ID.Village, CacheManager.InstantiatePlayers); }
private void ListeningForPacakage(Decipher decipher) { Package = JsonUtility.FromJson <Package>(decipher.content); Package.Initialize(); }
public Cipher(Factory factory) { encrypt = factory.createEncrypt(); decipher = factory.createDecipher(); }
public Cipher(Factory factory, int i) { encrypt = factory.createEncrypt(i); decipher = factory.createDecipher(i); }
private void UpdateLoadingText(Decipher decipher) { LoadingUI.LoadingText = decipher.content; }