From 5ae9a68f63d7854e4576ea0eab88dae3c5ee5cb2 Mon Sep 17 00:00:00 2001 From: flashwave Date: Tue, 30 Jul 2024 22:26:01 +0000 Subject: [PATCH] Added hidoi/hajime hash endpoint for if I need it for some reason. --- src/MakaiContext.php | 2 +- .../{RandomStringRoutes.php => ToolsRoutes.php} | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) rename src/Tools/{RandomStringRoutes.php => ToolsRoutes.php} (73%) diff --git a/src/MakaiContext.php b/src/MakaiContext.php index 2e9bb94..52e38c8 100644 --- a/src/MakaiContext.php +++ b/src/MakaiContext.php @@ -94,7 +94,7 @@ final class MakaiContext { $routingCtx->register(new DeveloperRoutes($this->templating, $this->contacts, $this->projects)); $routingCtx->register(new AssetsRoutes($this->siteInfo)); $routingCtx->register(new SSHKeys\SSHKeysRoutes($this->sshKeys)); - $routingCtx->register(new Tools\RandomStringRoutes); + $routingCtx->register(new Tools\ToolsRoutes); $routingCtx->register(new Tools\Ascii\AsciiRoutes($this->templating)); $routingCtx->register(new Tools\Whois\WhoisRoutes($this->templating, $this->csrfp)); diff --git a/src/Tools/RandomStringRoutes.php b/src/Tools/ToolsRoutes.php similarity index 73% rename from src/Tools/RandomStringRoutes.php rename to src/Tools/ToolsRoutes.php index 3ff7901..dccd58a 100644 --- a/src/Tools/RandomStringRoutes.php +++ b/src/Tools/ToolsRoutes.php @@ -4,7 +4,7 @@ namespace Makai\Tools; use Index\XString; use Index\Http\Routing\{HttpGet,RouteHandler}; -class RandomStringRoutes extends RouteHandler { +class ToolsRoutes extends RouteHandler { #[HttpGet('/tools/random')] public function getRandomString($response, $request): string { $response->setTypePlain(); @@ -22,6 +22,16 @@ class RandomStringRoutes extends RouteHandler { return $out; } + #[HttpGet('/tools/hajime-hash')] + #[HttpGet('/tools/hidoi-hash')] + public function getHajimeHash($response, $request): string { + $response->setTypePlain(); + if(!$request->hasParam('text')) + return 'text param is empty'; + + return hash('sha256', strrev(hash('sha256', (string)$request->getParam('text')))); + } + #[HttpGet('/key.php')] #[HttpGet('/rngstr')] public function getRedirect($response, $request): void {