From 97de1974aaad07a3619af16457cc6f0b6e1d6af9 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sun, 12 Jun 2016 13:40:28 +0100 Subject: [PATCH] Update hash module. --- modules/action-hash.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/action-hash.php b/modules/action-hash.php index 09d4123..30fb53d 100644 --- a/modules/action-hash.php +++ b/modules/action-hash.php @@ -1,11 +1,18 @@ "Password hashing action", - "version" => "0.5", + "version" => "0.6", "author" => "Starbeamrainbowlabs", "description" => "Adds a utility action (that anyone can use) called hash that hashes a given string. Useful when changing a user's password.", "id" => "action-hash", "code" => function() { + /** + * @api {get} ?action=hash&string={text} Hash a password + * @apiName Hash + * @apiGroup Utility + * @apiParam {string} string The string to hash. + * @apiParam {boolean} raw Wherher to return the hashed password as a raw string instead of as part of an HTML page. + */ /* * ██ ██ █████ ███████ ██ ██ @@ -14,7 +21,6 @@ register_module([ * ██ ██ ██ ██ ██ ██ ██ * ██ ██ ██ ██ ███████ ██ ██ */ - add_action("hash", function() { global $settings; @@ -24,6 +30,11 @@ register_module([ exit(page_renderer::render_main("Missing parameter", "

The GET parameter string must be specified.

It is strongly recommended that you utilise this page via a private or incognito window in order to prevent your password from appearing in your browser history.

")); } + else if(!empty($_GET["raw"])) + { + header("content-type: text/plain"); + exit(hash_password($_GET["string"])); + } else { exit(page_renderer::render_main("Hashed string", "

Algorithm: " . ($settings->use_sha3 ? "sha3" : "sha256") . "

\n

" . $_GET["string"] . "" . hash_password($_GET["string"]) . "

"));