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 | |
| parent | d90b51ce89bcc693e3014b313fe8e3b975031adf (diff) | |
| download | classroom-21fedb3af692b12c1f0aa266bbf788b01f2cbe4c.tar.gz classroom-21fedb3af692b12c1f0aa266bbf788b01f2cbe4c.tar.bz2 classroom-21fedb3af692b12c1f0aa266bbf788b01f2cbe4c.zip | |
auth tests
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/auth.php | 58 | ||||
| -rw-r--r-- | tests/register.php | 43 |
2 files changed, 101 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 diff --git a/tests/register.php b/tests/register.php new file mode 100644 index 0000000..7f778af --- /dev/null +++ b/tests/register.php @@ -0,0 +1,43 @@ +<?php +$userManager = new UserManager(); + +$password = $userManager->cryptPassword('102030!!!'); + +$user = (new User()) + ->setUserName('geo@roptron.gr') + ->setPassword($password) + ->setRoles([1]); + +$userManager->createUserToken($user); + + +$algos = [ + password_hash('root1234', PASSWORD_DEFAULT, ['cost' => 10 ]), + password_hash('root1234', PASSWORD_ARGON2I, ['cost' => 10 ]), + password_hash('root1234', CRYPT_BLOWFISH, ['cost' => 10 ]), + password_hash('root1234', PASSWORD_DEFAULT, ['cost' => 9 ]), + password_hash('root1234', PASSWORD_ARGON2I, ['cost' => 9 ]), + password_hash('root1234', CRYPT_BLOWFISH, ['cost' => 9 ]), + password_hash('root1234', PASSWORD_DEFAULT, ['cost' => 11 ]), + password_hash('root1234', PASSWORD_ARGON2I, ['cost' => 11 ]), + password_hash('root1234', CRYPT_BLOWFISH, ['cost' => 11 ]), + password_hash('root1234', PASSWORD_DEFAULT, ['cost' => 12 ]), + password_hash('root1234', PASSWORD_ARGON2I, ['cost' => 12 ]), + password_hash('root1234', CRYPT_BLOWFISH, ['cost' => 12 ]), + password_hash('root1234', PASSWORD_DEFAULT, ['cost' => 8 ]), + password_hash('root1234', PASSWORD_ARGON2I, ['cost' => 8 ]), + password_hash('root1234', CRYPT_BLOWFISH, ['cost' => 8 ]), + password_hash('root1234', PASSWORD_DEFAULT, ['cost' => 7 ]), + password_hash('root1234', PASSWORD_ARGON2I, ['cost' => 7 ]), + password_hash('root1234', CRYPT_BLOWFISH, ['cost' => 7 ]) + +] +?><pre><?php + +foreach($algos as $a) { + echo $a ."\n"; +} + + + +?></pre>
\ No newline at end of file |
