From 3f2daf1283a6ba885017f68c589237e07bdccd6d Mon Sep 17 00:00:00 2001 From: Ivan Djurdjevac Date: Wed, 11 Oct 2017 09:45:37 +0000 Subject: [PATCH 01/10] Caclulating hash time --- function.php | 9 ++++++++- index.php | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/function.php b/function.php index 94edd7b..abab432 100644 --- a/function.php +++ b/function.php @@ -1,8 +1,15 @@ \ No newline at end of file diff --git a/index.php b/index.php index 7eaa87a..393b0df 100644 --- a/index.php +++ b/index.php @@ -32,6 +32,7 @@

Hash:

+ Execution time: nanoseconds
From 8b19949b8516b858e18605c3ca666b2bc48636e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adnan=20Ki=C4=8Din?= Date: Wed, 11 Oct 2017 11:50:00 +0200 Subject: [PATCH 02/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc8c4a2..c60c264 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # hashr ### _Password hash generator_ -List of all PHP hashing algorithms ([hash_algos() function](http://php.net/manual/en/function.hash-algos.php)) and their result for an input string. +List of all PHP hashing algorithms ([hash_algos() function](http://php.net/manual/en/function.hash-algos.php)) and their result (and hashing time) for an input string. From 8d60433dec0823c5e5698c81b8d642034e6f5239 Mon Sep 17 00:00:00 2001 From: TheAdnan Date: Wed, 11 Oct 2017 12:32:53 +0200 Subject: [PATCH 03/10] fonts --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index 393b0df..bcb79b8 100644 --- a/index.php +++ b/index.php @@ -32,7 +32,7 @@

Hash:

- Execution time: nanoseconds + Execution time: nanoseconds
From 85ace7f02ac9976518d7f4a1c34c2e45174daaa8 Mon Sep 17 00:00:00 2001 From: vaani98 <31743499+vaani98@users.noreply.github.com> Date: Wed, 11 Oct 2017 16:05:04 +0530 Subject: [PATCH 04/10] Update index.php --- index.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index 393b0df..466553b 100644 --- a/index.php +++ b/index.php @@ -18,9 +18,23 @@ } + -
+ @@ -39,5 +53,3 @@ - - From 418c825a4303378219a21cc70225017729297155 Mon Sep 17 00:00:00 2001 From: vaani98 <31743499+vaani98@users.noreply.github.com> Date: Wed, 11 Oct 2017 16:29:48 +0530 Subject: [PATCH 05/10] Update index.php --- index.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/index.php b/index.php index 466553b..28522aa 100644 --- a/index.php +++ b/index.php @@ -18,20 +18,6 @@ } - @@ -51,5 +37,19 @@ function validateform() + From e8ece7b896b97351fbc2d918b3b22ca7a0de6594 Mon Sep 17 00:00:00 2001 From: TheAdnan Date: Wed, 11 Oct 2017 14:30:04 +0200 Subject: [PATCH 06/10] css edits --- index.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.php b/index.php index c149781..f2d6b28 100644 --- a/index.php +++ b/index.php @@ -9,6 +9,8 @@ From e3656b825850f9239020901d2482566c8918fb1a Mon Sep 17 00:00:00 2001 From: TheAdnan Date: Wed, 11 Oct 2017 14:32:54 +0200 Subject: [PATCH 07/10] algo function fix --- function.php | 3 +-- index.php | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/function.php b/function.php index abab432..f13e718 100644 --- a/function.php +++ b/function.php @@ -8,8 +8,7 @@ $hash = hash($algo, $_POST['input']); $timeElapsed = microtime(true) - $start; $hashTime[$algo] = $timeElapsed; - - array_push($hashes, $hash); + $hashes[$algo] = $hash; } } ?> \ No newline at end of file diff --git a/index.php b/index.php index f2d6b28..c8ed33d 100644 --- a/index.php +++ b/index.php @@ -35,10 +35,10 @@
$algo) { ?> + foreach (hash_algos() as $algo) { ?>

-

Hash:

+

Hash:

Execution time: nanoseconds
Date: Wed, 11 Oct 2017 14:19:44 +0100 Subject: [PATCH 08/10] remove input validation js function and replace with HTML input validation --- index.php | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/index.php b/index.php index c8ed33d..6d304f9 100644 --- a/index.php +++ b/index.php @@ -29,7 +29,7 @@ - +
@@ -44,19 +44,5 @@
- From b6c1357409bedb65e48bac4c7e52b16fd21fb17d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adnan=20Ki=C4=8Din?= Date: Wed, 11 Oct 2017 15:42:28 +0200 Subject: [PATCH 09/10] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index c60c264..e40d853 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,6 @@ ### _Password hash generator_ List of all PHP hashing algorithms ([hash_algos() function](http://php.net/manual/en/function.hash-algos.php)) and their result (and hashing time) for an input string. + + +#### The app is deployed on heroku: [Hashr](https://hashr-php.herokuapp.com/) From 6e5e145c1e241b217da845fbfb50eb06a8886c29 Mon Sep 17 00:00:00 2001 From: Patrick Dorival Date: Thu, 12 Oct 2017 03:04:28 +1100 Subject: [PATCH 10/10] Using AJAX for form submission --- ajax.js | 35 +++++++++++++++++++++++++++++++++++ calculate_hashes.php | 13 +++++++++++++ function.php | 5 ++--- index.php | 21 +++++---------------- 4 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 ajax.js create mode 100644 calculate_hashes.php diff --git a/ajax.js b/ajax.js new file mode 100644 index 0000000..5858201 --- /dev/null +++ b/ajax.js @@ -0,0 +1,35 @@ +function ready(fn) { + if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){ + fn(); + } else { + document.addEventListener('DOMContentLoaded', fn); + } +} + +ready(function() { + + document.hashform.addEventListener('submit', function(e) { + e.preventDefault(); + + var unhashedString = document.getElementById('unhashed-string'), + data = 'input=' + unhashedString.value.trim(); + + var request = new XMLHttpRequest(); + request.open('POST', 'calculate_hashes.php', true); + + request.onload = function() { + + if (this.status >= 200 && this.status < 400) { + + var hashesContainer = document.getElementById('hashes-container'); + + if (hashesContainer) { + hashesContainer.innerHTML = this.response; + } + } + }; + + request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); + request.send(data); + }); +}); \ No newline at end of file diff --git a/calculate_hashes.php b/calculate_hashes.php new file mode 100644 index 0000000..5a4f961 --- /dev/null +++ b/calculate_hashes.php @@ -0,0 +1,13 @@ + $algo) +{ + ?> +
+

+

Hash:

+ Execution time: nanoseconds +
+ \ No newline at end of file + } \ No newline at end of file diff --git a/index.php b/index.php index 6d304f9..ab88856 100644 --- a/index.php +++ b/index.php @@ -1,11 +1,9 @@ - Hashr +