Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

encrypted passwords (i need help ASAP!) 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
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:<br><br>-------------------<br>membership number;<br>[space]<br>lastname, firstname<br>--------------------<br>membership number;<br>[space] <br>lastname, firstname<br>--------------------<br><br>I would like to use a Perl script to create the .htpasswd file, because the htpasswd program on my web server is disabled.&nbsp;&nbsp;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.&nbsp;&nbsp;Can you help me?<br>
 
This is typed from memory and may have minor syntax problems, but hopefully the flow will be helpful.<br><br><FONT FACE=monospace><br># read the existing passwd file and stuff it into a hash<br>open(PASS,&quot;.htpasswd&quot;) ¦¦ die;<br>while (&lt;PASS&gt;) { $buff .= $_; }<br>close PASS;<br><br>@members = split(/--------------------/,$buff);<br>foreach $member (@members)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;@parts = split(/\n/,$member);<br>&nbsp;&nbsp;&nbsp;&nbsp;$memberPasswds{$parts[0]} = $parts[2];<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br># since you can not un-crypt passwords, you must crypt what the user submits and <br># test that against the stored password<br><br>$user = $FORM{'user'}; # user from html submit<br>$pass = $FORM{'pass'}; # password from html submit<br>$pass = crypt($pass);&nbsp;&nbsp;&nbsp;&nbsp;# crypt the submitted password<br><br># get stored password for the submitted user.<br>$storedPass = $memberPasswds{$user};<br><br># check submitted against stored.<br>unless ($pass eq $storedPass) { print &quot;Go Away&quot;;&nbsp;&nbsp;}<br><br></font> <p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top