bachoA4o has asked for the wisdom of the Perl Monks concerning the following question:
and this is how is stored in the database#!/usr/bin/perl use strict; use warnings; use DBI; use CGI::Simple; use Crypt::Argon2 qw/argon2id_pass argon2id_verify/; sub user_crypt;sub createUser; sub user_crypt { my ($cryUser , $cryPass)=@_; my $salt = rand(16); my $encode = argon2id_pass($cryPass,$salt,3,'32M',1,16); createUser($cryUser,$encode); } sub createUser{ my ($user , $hashPass)=@_; my $statement="INSERT INTO LOGIN_DATA(USER_NAME,USER_HASH) VALUES(?,?) +"; my $driver="mysql"; my $database="USERS"; my $dsn="DBI:$driver:database=$database"; my $databaseUser="root"; my $databasePass=""; my $dbcon= DBI->connect($dsn,$databaseUser,$databasePass) or die $!; my $preState = $dbcon->prepare($statement) ; $preState->execute($user , $hashPass) or die $!; } my $username=CGI::Simple->new; my $pass=CGI::Simple->new; $username->param('textfield'); $pass->param('pass'); user_crypt($username,$pass); print "Content-type: text/html\n\n"; print "<html><body>\n"; print "<h1>Random heading</h1>\n"; print "$username , $pass"; print "</body></html>\n";
and after the program that verifies but of course it's not working because don`t know how to fetch the username .CGI::Simple=HASH(0x55bb333591e0) | $argon2id$v=19$m=32768,t=3,p=1$MTMu +ODI1NjU0MDY4Mjc3OQ$V83Q4GNnwnY1187C/whS/Q
#!/usr/bin/perl use strict; use warnings; use Crypt::Argon2 qw/argon2id_pass argon2id_verify/; use DBI; sub get_data; sub chec_pass; sub get_data{ my ($user , $hash_pass); my $statement = "SELECT * FROM LOGIN_DATA"; my $driver = "mysql"; my $database = "USERS"; my $dsn = "DBI:$driver:database=$database"; my $dataUsr = "root"; my $dataPass = ""; my $dbcon = DBI->connect($dsn,$dataUsr,$dataPass) or die $!; my $preState = $dbcon->prepare($statement); $preState->execute(); my @row; while (@row = $preState->fetchrow_array()) { } } sub chec_pass { my ($user, $password) = @_; my $encoded = fetch_encoded($user); return argon2id_verify($encoded , $password); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Login form
by Your Mother (Archbishop) on Sep 18, 2018 at 06:45 UTC | |
|
Re: Login form
by Athanasius (Archbishop) on Sep 18, 2018 at 06:48 UTC | |
|
Re: Login form
by hippo (Archbishop) on Sep 18, 2018 at 08:37 UTC | |
|
Re: Login form
by poj (Abbot) on Sep 18, 2018 at 11:23 UTC |