CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
how do i un encrypt a password?

 



keith2045
Deleted

Mar 5, 2001, 4:05 PM

Post #1 of 3 (171 views)
how do i un encrypt a password? Can't Post

how do i un encrypt a password? I have a logon page and it compairs the user name and password and if it matches it goes to the logon screen. I can get everything else but i cant compair the passwords because the one in my database is encrypted. How do i do this?

Keith



zanardi
journeyman

Mar 5, 2001, 4:23 PM

Post #2 of 3 (170 views)
Re: how do i un encrypt a password? [In reply to] Can't Post

you can't uncrypt a user password, that would pretty much defeat the perpose of encrypting them.

this is what you do, you have someone register or whatever, they type in the password they want, you encrypt it into your database, now the password is protected from outsiders, now when the user logs on, they type in their password, you encrypt it agian and then match up the encrypted password.

----------------------
Fueled By ZCom


Jasmine
Administrator / Moderator

Mar 5, 2001, 4:55 PM

Post #3 of 3 (169 views)
Re: how do i un encrypt a password? [In reply to] Can't Post

If you're using crypt to encrypt the password, then the first 2 characters of the saved, encrypted password is the "salt" that was used to encrypt the password.

With that information, you can compare the user-submitted pw to the encrypted pw by seasoning (encrypting) the submitted pw with the same salt.

eg:


Code
my $matchthispw = $in->param( 'password' ); 

while ( <PWFILE> ){
chomp;
my ( $username, $encryptedpw ) = split /\t/;
my $salt = substr( $encryptedpw, 0, 2 );
my $pwmatched = 1 if crypt( $matchthispw, $salt ) eq $encryptedpw;
}

Hope this helps!


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives