Forum Moderators: coopster & phranque

Message Too Old, No Replies

Perl Encryption

         

typomaniac

2:30 am on Jul 28, 2022 (gmt 0)

10+ Year Member Top Contributors Of The Month



I’m planning to re-build an admin screen using PERL which is currently written in PHP. For passwords it is using PASSWORD_BCRYPT which is atleast a few years old.
I was thinking about using the Crypt function (Perl).
Is either one of these better than the other, and why?
I'm far from being a great "scripter" but I find PERL easier to work with.

csdude55

6:21 pm on Aug 15, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have no experience with PASSWORD_BCRYPT, but Perl's crypt is a one-way encoder with no decrypt... like MD5. So you can compare what's entered to what's stored by encrypting the entry, but there's no way to reverse it and say "THIS is the password".

Personally, I use MD5 instead.

typomaniac

3:56 pm on Aug 16, 2022 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thank you so much csdude55 for the response. I like the idea of using MD5 as I only need to compare the encrypted. The PASSWORD_BCRYPT is a PHP I've used for a few years but I'm converting everything to perl. The crypt function didn't look to "hefty" for the job.
Thanks once again and hoping you have a great day.

Brett_Tabke

12:58 am on Aug 21, 2022 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Super easy with crypt:

$hashword = crypt ( $mypassword, "friedrice" ); #convert pass word into a hash.

Now just compare what a user input to the stored "$hashword" on disk.

$temphashword = crypt ( $UserSubmitted, "friedrice" ); #take user input from login for and encrypt it.

$accessapproved++ if $temphashword eq $hasword; #compare the two to see if they are the same