×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

encrypted passwords (i need help ASAP!)

encrypted passwords (i need help ASAP!)

encrypted passwords (i need help ASAP!)

(OP)
I am in the process of implementing password protection for some areas of my website using .htaccess and .htpasswd files. I have a member database (saved as a text file) with members listed in the following format:

-------------------
membership number;
[space]
lastname, firstname
--------------------
membership number;
[space]
lastname, firstname
--------------------

I would like to use a Perl script to create the .htpasswd file, because the htpasswd program on my web server is disabled.  I am using the crypt() function to encrypt the passwords, but I don't know what to write to make to script check to database and select the lastname as the username and the membership number as the password.  Can you help me?

RE: encrypted passwords (i need help ASAP!)

This is typed from memory and may have minor syntax problems, but hopefully the flow will be helpful.


# read the existing passwd file and stuff it into a hash
open(PASS,".htpasswd") ¦¦ die;
while (<PASS>) { $buff .= $_; }
close PASS;

@members = split(/--------------------/,$buff);
foreach $member (@members)
    {
    @parts = split(/\n/,$member);
    $memberPasswds{$parts[0]} = $parts[2];
    }

# since you can not un-crypt passwords, you must crypt what the user submits and
# test that against the stored password

$user = $FORM{'user'}; # user from html submit
$pass = $FORM{'pass'}; # password from html submit
$pass = crypt($pass);    # crypt the submitted password

# get stored password for the submitted user.
$storedPass = $memberPasswds{$user};

# check submitted against stored.
unless ($pass eq $storedPass) { print "Go Away";  }




keep the rudder amid ship and beware the odd typo

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close