Hello I'm making a a form that create a user with username and password and then crypts the data and store it in database ; password crypting is working fine i think but stores the name as CGI::Simple=HASH(0x55bb333591e0). Here is the code for creating the user:
#!/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 this is how is stored in the database
CGI::Simple=HASH(0x55bb333591e0) | $argon2id$v=19$m=32768,t=3,p=1$MTMu +ODI1NjU0MDY4Mjc3OQ$V83Q4GNnwnY1187C/whS/Q
and after the program that verifies but of course it's not working because don`t know how to fetch the username .
#!/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); }

In reply to Login form by bachoA4o

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.