1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-25 17:23:00 +00:00

Update hash module.

This commit is contained in:
Starbeamrainbowlabs 2016-06-12 13:40:28 +01:00
parent 0c47056fc8
commit 97de1974aa

View file

@ -1,11 +1,18 @@
<?php <?php
register_module([ register_module([
"name" => "Password hashing action", "name" => "Password hashing action",
"version" => "0.5", "version" => "0.6",
"author" => "Starbeamrainbowlabs", "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.", "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", "id" => "action-hash",
"code" => function() { "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() { add_action("hash", function() {
global $settings; global $settings;
@ -24,6 +30,11 @@ register_module([
exit(page_renderer::render_main("Missing parameter", "<p>The <code>GET</code> parameter <code>string</code> must be specified.</p> exit(page_renderer::render_main("Missing parameter", "<p>The <code>GET</code> parameter <code>string</code> must be specified.</p>
<p>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.</p>")); <p>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.</p>"));
} }
else if(!empty($_GET["raw"]))
{
header("content-type: text/plain");
exit(hash_password($_GET["string"]));
}
else else
{ {
exit(page_renderer::render_main("Hashed string", "<p>Algorithm: " . ($settings->use_sha3 ? "sha3" : "sha256") . "</p>\n<p><code>" . $_GET["string"] . "</code> → <code>" . hash_password($_GET["string"]) . "</code></p>")); exit(page_renderer::render_main("Hashed string", "<p>Algorithm: " . ($settings->use_sha3 ? "sha3" : "sha256") . "</p>\n<p><code>" . $_GET["string"] . "</code> → <code>" . hash_password($_GET["string"]) . "</code></p>"));