/// <summary> /// Create the Mask Table the PayloadMasker will use /// </summary> /// <param name="Seed">The seed will be used to randomize the start position</param> /// <param name="MaxLength">The maximum length in bytes to bruteforce</param> /// <param name="OutStream">The stream for writing the output</param> public static void CreateMaskTable(int Seed, ushort MaxLength, Stream OutStream) { if (!OutStream.CanWrite) { throw new Exception("OutStream does not have Write"); } if (MaxLength <= 0) { throw new Exception("MaxLength should be atleast 1 or higher"); } Stopwatch sw = Stopwatch.StartNew(); ulong Speed = 0; double PrevVal = 0; double MaxVal = 0; List <double> Digits = new List <double>(); DataShuffler dataShuffler = new DataShuffler(Seed); for (double i = 0, h = 8; i < MaxLength; i++, h += 8) { int ByteIndex = (int)i + 1; PrevVal = MaxVal; MaxVal = Math.Pow(2, h); ProgressHelper progressHelper = new ProgressHelper((ulong)(MaxVal - PrevVal)); for (double j = PrevVal; j < MaxVal; j++) { byte[] num = BitConverter.GetBytes((ulong)j); Speed++; Digits.Add(j); progressHelper.Update(1); if (Digits.Count > 10000000) { SaveMaskTable(ref Digits, ref dataShuffler, ByteIndex, ref OutStream); } if (sw.ElapsedMilliseconds >= 1000) { Console.WriteLine(num[0].ToString("X4") + " " + num[1].ToString("X4") + " " + num[2].ToString("X4") + " " + num[3].ToString("X4") + " " + num[4].ToString("X4") + " " + num[5].ToString("X4") + " " + num[6].ToString("X4") + " " + num[7].ToString("X4")); TimeSpan ETA = progressHelper.TimeLeft; Console.WriteLine("Speed " + Speed + " a second, current byte length: " + ByteIndex + ", " + progressHelper.Progress + "% done, Time Left:" + ETA.Hours.ToString("D2") + ":" + ETA.Minutes.ToString("D2") + ":" + ETA.Seconds.ToString("D2")); Speed = 0; sw = Stopwatch.StartNew(); } } SaveMaskTable(ref Digits, ref dataShuffler, ByteIndex, ref OutStream); } }
public IActionResult Post([FromBody] DiscardRequest request) { // 捨牌 request.Attach(); var response = DiProvider.GetContainer().GetInstance <DiscardReceiver>().Receive(request); response.Detach(request.RoomKey); // 進行状況の更新 ProgressHelper.Update(request.RoomKey); // 通知 this.NotifyRoomContext(request.RoomKey); return(Ok(response)); }
public IActionResult Post([FromBody] CalcScoreRequest request) { request.Attach(); // 点数計算 var response = DiProvider.GetContainer().GetInstance <CalcScoreReceiver>().Receive(request); // 進行状況の更新 var room = request.Room; var player = room.GetPlayer(request.PlayerKey); ProgressHelper.Update(request.RoomKey, player.Wind); // 通知 this.NotifyRoomContext(request.RoomKey); return(Ok(response)); }
public IActionResult Post([FromBody] AiDiscardRequest request) { // 捨牌 request.Attach(); request.Wind = RoomManager.Get(request.RoomKey).Turn; request.Discardable = DiProvider.GetContainer().GetInstance <DrawnTileDiscardExecutor>(); var response = DiProvider.GetContainer().GetInstance <AiDiscardReceiver>().Receive(request); response.Detach(request.RoomKey); // 進行状況の更新 ProgressHelper.Update(request.RoomKey); // 通知 this.NotifyRoomContext(request.RoomKey); return(Ok(response)); }
public IActionResult Post([FromBody] CalcScoreRequest request) { request.Attach(); // 最後の捨牌を追加 var room = request.Room; var player = room.GetPlayer(request.PlayerKey); room.Context.Hands[player.Wind.ToInt()].Add(room.GetLastDiscardTile()); // 点数計算 var response = DiProvider.GetContainer().GetInstance <CalcScoreReceiver>().Receive(request); // 進行状況の更新 ProgressHelper.Update(request.RoomKey, player.Wind); // 通知 this.NotifyRoomContext(request.RoomKey); return(Ok(response)); }