summaryrefslogtreecommitdiff
path: root/tests/auth.php
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-26 04:50:46 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-26 04:50:46 +0300
commit21fedb3af692b12c1f0aa266bbf788b01f2cbe4c (patch)
treee600e16a2894407eba840e7694a4f290669e31d8 /tests/auth.php
parentd90b51ce89bcc693e3014b313fe8e3b975031adf (diff)
downloadclassroom-21fedb3af692b12c1f0aa266bbf788b01f2cbe4c.tar.gz
classroom-21fedb3af692b12c1f0aa266bbf788b01f2cbe4c.tar.bz2
classroom-21fedb3af692b12c1f0aa266bbf788b01f2cbe4c.zip
auth tests
Diffstat (limited to 'tests/auth.php')
-rw-r--r--tests/auth.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/auth.php b/tests/auth.php
new file mode 100644
index 0000000..26c057a
--- /dev/null
+++ b/tests/auth.php
@@ -0,0 +1,58 @@
+<?php
+
+class Pass_test
+{
+ use PasswordTrait;
+
+
+ public function isTextPasswordValid($plain, $hash): bool
+ {
+ return password_verify($plain, $hash);
+ }
+}
+
+
+$pass = new Pass_test();
+
+$password = [
+ '102030!!!',
+ '1234',
+ 'password'
+];
+
+
+$hash = [];
+$verify = [];
+
+
+// create pass hashes
+foreach($password as $val)
+{
+ $x = $pass->cryptPassword($val);
+ $hash[] = $x;
+}
+?>
+<html>
+ <head>
+ <title>Dev Tools</title>
+ </head>
+ <body>
+ <h2>crypt passwords; then...</h2>
+ <h2>check password validation</h2>
+<pre>
+<?php
+
+
+for($i=0 ; $i < 3 ; $i++) {
+ echo $i ."> ". $password[$i] ." -> ". $hash[$i]. "\n";
+ $verify[$i] = ($pass->isTextPasswordValid($password[$i], $hash[$i])) ? 'valid' : 'not-match';
+}
+
+?>
+</pre>
+ <?php print_r( $hash ); ?>
+
+ <?php print_r( $verify ); ?>
+ </pre>
+ </body>
+</html> \ No newline at end of file