diff --git a/docs/accept.md b/docs/accept.md index 87326bb9..1358fdd1 100644 --- a/docs/accept.md +++ b/docs/accept.md @@ -11,14 +11,14 @@ Accepts an invitation to play online with an opponent. ### Example ```js -ws.send('/accept 15f78c0035a719491b89522b4905a490'); +ws.send('/accept e69e3228e22dbcab5c2274646ae9a23647b222d084e26dea3216016d026f7108'); ``` ```text { "/accept": { "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJwY2hlc3MubmV0IiwiaWF0IjoxNjk0NDQxOTcxLCJleHAiOjE2OTQ0NDU1NzEsInZhcmlhbnQiOiJjbGFzc2ljYWwiLCJzdWJtb2RlIjoiZnJpZW5kIiwiY29sb3IiOiJ3IiwibWluIjo1LCJpbmNyZW1lbnQiOjMsImZlbiI6InJuYnFrYm5yL3BwcHBwcHBwLzgvOC84LzgvUFBQUFBQUFAvUk5CUUtCTlIgdyBLUWtxIC0ifQ.POuK_cR3U_bblLa8LFyGg1AJEE5_iW_AquuNn7K4qHI", - "hash": "15f78c0035a719491b89522b4905a490", + "hash": "e69e3228e22dbcab5c2274646ae9a23647b222d084e26dea3216016d026f7108", "timer": { "w": 300, "b": 300 diff --git a/docs/online-games.md b/docs/online-games.md index ccc6f084..38807abb 100644 --- a/docs/online-games.md +++ b/docs/online-games.md @@ -23,7 +23,7 @@ ws.send('/online_games'); "min": 5, "increment": 1, "fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -", - "hash": "84a4e20138e54e1869b9b79e7d3111f1" + "hash": "d1a4f2f3688e3211e94fe643a679204806cd196303e44522e833815e4f728c65" }, { "iss": "async.chesslablab.org", @@ -36,7 +36,7 @@ ws.send('/online_games'); "increment": 5, "fen": "bqrnnbkr/pppppppp/8/8/8/8/PPPPPPPP/BQRNNBKR w KQkq -", "startPos": "BQRNNBKR", - "hash": "c6b79ac68055766c2a33364f69c72e4c" + "hash": "e71a27a35d021acfe9ad819348ec2c574f1962aa14fddc58df379d0b3c225cc8" }, { "iss": "async.chesslablab.org", @@ -48,7 +48,7 @@ ws.send('/online_games'); "min": 30, "increment": 10, "fen": "rnabqkbcnr/pppppppppp/10/10/10/10/PPPPPPPPPP/RNABQKBCNR w KQkq -", - "hash": "076bafad0559def2db7866609680074c" + "hash": "2e2c447c902a34f55145769fe9454cf055a6b3e7658756ade2b2ac783d24c568" } ] } diff --git a/docs/restart.md b/docs/restart.md index bc49cc0d..fbe1bf97 100644 --- a/docs/restart.md +++ b/docs/restart.md @@ -18,7 +18,7 @@ ws.send('/restart ffc536a8f44fc21b4d254e4fb85d7e33'); { "/restart": { "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJwY2hlc3MubmV0IiwiaWF0IjoxNjk0MTAxOTI2LCJleHAiOjE2OTQxMDU1MjYsInZhcmlhbnQiOiJjbGFzc2ljYWwiLCJzdWJtb2RlIjoib25saW5lIiwiY29sb3IiOiJ3IiwibWluIjo1LCJpbmNyZW1lbnQiOjMsImZlbiI6InJuYnFrYm5yL3BwcHBwcHBwLzgvOC84LzgvUFBQUFBQUFAvUk5CUUtCTlIgdyBLUWtxIC0ifQ.sE6Is9GYf0R6l0_C8rt7VPE8fVChsYlb9teEQw_2QUQ", - "hash": "23bb4c7ec2e5a33f436b41376bb41064", + "hash": "5665d2e6c84344db95aa9fdbb3bc196b88238bce22a1c58a41f2f269deee6c33", "timer": { "w": 300, "b": 300 diff --git a/docs/start.md b/docs/start.md index f8331c4e..0a324ec2 100644 --- a/docs/start.md +++ b/docs/start.md @@ -133,8 +133,8 @@ ws.send('/start classical play {"min":5,"increment":3,"color":"b","submode":"onl "variant": "classical", "mode": "play", "fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -", - "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjaGVzc2xhYmxhYi5uZXQiLCJpYXQiOjE3MDQ5ODM1NzUsImV4cCI6MTcwNDk4NzE3NSwidmFyaWFudCI6ImNsYXNzaWNhbCIsInN1Ym1vZGUiOiJvbmxpbmUiLCJjb2xvciI6ImIiLCJtaW4iOjUsImluY3JlbWVudCI6MywiZmVuIjoicm5icWtibnIvcHBwcHBwcHAvOC84LzgvOC9QUFBQUFBQUC9STkJRS0JOUiB3IEtRa3EgLSJ9.DMIDU7I52Reuz0VNHTXlGn6FLv3dc6KMEZRf9ephh1k", - "hash": "3d5f1b067edae5a59a2a9595e96bde54" + "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhc3luYy5jaGVzc2xhYmxhYi5vcmciLCJpYXQiOjE3MTA1MjM2MzUsImV4cCI6MTcxMDUyNzIzNSwidmFyaWFudCI6ImNsYXNzaWNhbCIsInN1Ym1vZGUiOiJvbmxpbmUiLCJjb2xvciI6InciLCJtaW4iOiI1IiwiaW5jcmVtZW50IjoiMyIsImZlbiI6InJuYnFrYm5yL3BwcHBwcHBwLzgvOC84LzgvUFBQUFBQUFAvUk5CUUtCTlIgdyBLUWtxIC0ifQ.gGEgw7zZmJk3ftnS9Yu-RcvhFBzc9eKbvF_45hrEt4E", + "hash": "db4a87907dfaaede54c56b3edddbe7e3a8c01803f8906be7bb7a2e180353ce58" } } ``` @@ -155,8 +155,8 @@ ws.send('/start classical play "{\\"min\\":5,\\"increment\\":3,\\"color\\":\\"w\ "variant": "classical", "mode": "play", "fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -", - "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJjaGVzc2xhYmxhYi5uZXQiLCJpYXQiOjE3MDQ5NjYwNTMsImV4cCI6MTcwNDk2OTY1MywidmFyaWFudCI6ImNsYXNzaWNhbCIsInN1Ym1vZGUiOiJmcmllbmQiLCJjb2xvciI6InciLCJtaW4iOjUsImluY3JlbWVudCI6MywiZmVuIjoicm5icWtibnIvcHBwcHBwcHAvOC84LzgvOC9QUFBQUFBQUC9STkJRS0JOUiB3IEtRa3EgLSJ9._ehztodTLYkyovW82I1qyGdNkFwGFdTKn3O7EBr3cHo", - "hash": "b4f1c0d0b28cad147968729f6bb76558" + "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhc3luYy5jaGVzc2xhYmxhYi5vcmciLCJpYXQiOjE3MTA1MjM5MzUsImV4cCI6MTcxMDUyNzUzNSwidmFyaWFudCI6ImNsYXNzaWNhbCIsInN1Ym1vZGUiOiJmcmllbmQiLCJjb2xvciI6ImIiLCJtaW4iOiI1IiwiaW5jcmVtZW50IjoiMyIsImZlbiI6InJuYnFrYm5yL3BwcHBwcHBwLzgvOC84LzgvUFBQUFBQUFAvUk5CUUtCTlIgdyBLUWtxIC0ifQ.Tl_loA70IUidZ9XG9Pw9osC9MZIHbxjg_eDMkGS6des", + "hash": "7eb1642c7d5faf2dee2e5dd5aef871c55fe29b5791c8e67746664e8f2517727c" } } ``` diff --git a/src/Command/AcceptPlayRequestCommand.php b/src/Command/AcceptPlayRequestCommand.php index dfb0eee6..b65029e4 100644 --- a/src/Command/AcceptPlayRequestCommand.php +++ b/src/Command/AcceptPlayRequestCommand.php @@ -58,7 +58,7 @@ public function run(ChesslaBlabSocket $socket, array $argv, int $id) return $socket->getClientStorage()->sendToMany($ids, [ $this->name => [ 'jwt' => $gameMode->getJwt(), - 'hash' => md5($gameMode->getJwt()), + 'hash' => hash('sha256', $gameMode->getJwt()), 'timer' => $gameMode->getTimer(), 'startedAt' => $gameMode->getStartedAt(), ], diff --git a/src/Command/RestartCommand.php b/src/Command/RestartCommand.php index e1392033..efd1cd0e 100644 --- a/src/Command/RestartCommand.php +++ b/src/Command/RestartCommand.php @@ -63,7 +63,7 @@ public function run(ChesslaBlabSocket $socket, array $argv, int $id) return $socket->getClientStorage()->sendToMany($newGameMode->getResourceIds(), [ $this->name => [ 'jwt' => $newJwt, - 'hash' => md5($newJwt), + 'hash' => hash('sha256', $newJwt), 'timer' => $newGameMode->getTimer(), ], ]); diff --git a/src/Command/StartCommand.php b/src/Command/StartCommand.php index 4e3a417c..f8bb7ed4 100644 --- a/src/Command/StartCommand.php +++ b/src/Command/StartCommand.php @@ -295,7 +295,7 @@ public function run(ChesslaBlabSocket $socket, array $argv, int $id) 'mode' => $argv[2], 'fen' => $game->getBoard()->toFen(), 'jwt' => $jwt, - 'hash' => md5($jwt), + 'hash' => hash('sha256', $jwt), ...($argv[1] === Game::VARIANT_960 ? ['startPos' => implode('', $game->getBoard()->getStartPos())] : [] diff --git a/src/Game/PlayMode.php b/src/Game/PlayMode.php index 1498186c..501147d3 100644 --- a/src/Game/PlayMode.php +++ b/src/Game/PlayMode.php @@ -35,7 +35,7 @@ public function __construct(Game $game, array $resourceIds, string $jwt) parent::__construct($game, $resourceIds); $this->jwt = $jwt; - $this->hash = md5($jwt); + $this->hash = hash('sha256', $jwt); $this->status = self::STATUS_PENDING; } @@ -126,7 +126,7 @@ public function res($argv, $cmd) 'timer' => $this->timer, ], ]; - + default: return parent::res($argv, $cmd); }