Hi Monks,

Firstly, I just want to apologise for what might seems like a pointless post. I am self teaching myself Perl (from a non coding background) and I have nobody to "bounce" ideas, syntax and coding methods off. I see most posts on this site are accompanied by large amounts of code whereas I find myself having the most difficulty with concepts.

Anyhoo, I do have some code I would like critiqued, if possible. It is a small function to hash a password and encrypt it using BlowFishCrypt.
I am unsure if it is actually doing what I think it is (I think its good but not certain). I am trying to take a password, add a random salt and insert into a users table. The dbh function is elsewhere but just connects to the database. Does this look good? Any comments or advice would be great.

sub add_user { my $dbh = new_dbh(); my $username = $_[0]; my $password = $_[1]; my $email = "$username\@email.com"; #change when live. my $ppr = Authen::Passphrase::BlowfishCrypt->new( cost => 12, salt_random => 1, passphrase => "$password"); my $hash = $ppr->hash_base64; my $salt = $ppr->salt_base64; my $sth = $dbh->prepare('INSERT users (users_id,user_name,password +,email,lib_id,department_id, permissions, session_id,salt) VALUES ("",?,?,?,"1","1","1","",?) ') or die "Couldn't prepare statement: " . $dbh->errstr; $sth->execute($username,$hash,$email,$salt) or die "Couldn't execu +te statement: " . $sth->errstr; $sth->finish; $dbh->disconnect; }

In reply to Authen::Passphrase::BlowfishCrypt - Create user. by packetstormer

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.