diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-26 04:50:46 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-03-26 04:50:46 +0300 |
| commit | 21fedb3af692b12c1f0aa266bbf788b01f2cbe4c (patch) | |
| tree | e600e16a2894407eba840e7694a4f290669e31d8 /tests/auth.php | |
| parent | d90b51ce89bcc693e3014b313fe8e3b975031adf (diff) | |
| download | classroom-21fedb3af692b12c1f0aa266bbf788b01f2cbe4c.tar.gz classroom-21fedb3af692b12c1f0aa266bbf788b01f2cbe4c.tar.bz2 classroom-21fedb3af692b12c1f0aa266bbf788b01f2cbe4c.zip | |
auth tests
Diffstat (limited to 'tests/auth.php')
| -rw-r--r-- | tests/auth.php | 58 |
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 |
