http://qs321.pair.com?node_id=1223034


in reply to with CGI, How to have multiple usernames and passwords from a txt file (password.txt) file

There are many problems with what you are doing, but the worst is working with plain text passwords. Never, ever, for any reason store plain text passwords, especially paired with user names!

A fairly light weight technique that is much more secure and needs very little extra work is to store a cryptographic hash of the password combined with a seed (often the user name can be used as the seed). To check a supplied password use the same hash process that was used to generate the hash originally then compare the two hash codes.

use strict; use warnings; use Digest::MD5; print Digest::MD5::md5_hex("username" . "SamplePassword");

Prints:

c0075ad4e26ec3dee225ccb6387b0b77
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond