diff --git a/README.md b/README.md index cc8c4a2..e40d853 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # 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. + + +#### The app is deployed on heroku: [Hashr](https://hashr-php.herokuapp.com/) 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 7eaa87a..ab88856 100644 --- a/index.php +++ b/index.php @@ -1,14 +1,14 @@ - Hashr + -
+ - +

-
- $algo) { ?> -
-

-

Hash:

-
- -
+
+ - -