Skip to content

Commit

Permalink
Replaced md5 with sha256
Browse files Browse the repository at this point in the history
  • Loading branch information
programarivm committed Mar 16, 2024
1 parent 1e7c46b commit 77acc03
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions docs/accept.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docs/online-games.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion docs/restart.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ws.send('/restart ffc536a8f44fc21b4d254e4fb85d7e33');
{
"/restart": {
"jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJwY2hlc3MubmV0IiwiaWF0IjoxNjk0MTAxOTI2LCJleHAiOjE2OTQxMDU1MjYsInZhcmlhbnQiOiJjbGFzc2ljYWwiLCJzdWJtb2RlIjoib25saW5lIiwiY29sb3IiOiJ3IiwibWluIjo1LCJpbmNyZW1lbnQiOjMsImZlbiI6InJuYnFrYm5yL3BwcHBwcHBwLzgvOC84LzgvUFBQUFBQUFAvUk5CUUtCTlIgdyBLUWtxIC0ifQ.sE6Is9GYf0R6l0_C8rt7VPE8fVChsYlb9teEQw_2QUQ",
"hash": "23bb4c7ec2e5a33f436b41376bb41064",
"hash": "5665d2e6c84344db95aa9fdbb3bc196b88238bce22a1c58a41f2f269deee6c33",
"timer": {
"w": 300,
"b": 300
Expand Down
8 changes: 4 additions & 4 deletions docs/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
```
Expand All @@ -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"
}
}
```
2 changes: 1 addition & 1 deletion src/Command/AcceptPlayRequestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
],
Expand Down
2 changes: 1 addition & 1 deletion src/Command/RestartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
],
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Command/StartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())]
: []
Expand Down
4 changes: 2 additions & 2 deletions src/Game/PlayMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -126,7 +126,7 @@ public function res($argv, $cmd)
'timer' => $this->timer,
],
];

default:
return parent::res($argv, $cmd);
}
Expand Down

0 comments on commit 77acc03

Please sign in to comment.