Well, that's another can of worms. Shown below is the method I'm using. I'm absolutely sure somebody will come along behind me with another method that is better or simpler, but this is just what I'm using because its convenient for me and I can use an automated script to make these whenever I need.
First, create a file (called .htaccess) that looks like this...
AuthName "Whatever You Want"
require user yourusername
Put the above file in the directory where you want password protection. The /path/to/your
should be the location of where you want to store the password file that we will create later. This can be in the same location as the .htaccess file, but many people recommend it be placed somewhere outside the document root. Personally, I think this kind of security isn't very strong and should not be used if you're trying to secure something extremely important like bank account info. If you're going to secure something that important, you really need to use SSL with this too. The "yourusername" should be whatever username you want people to enter when they login.
Now create another new file (mine is called "crypt_pass.pl") and put this inside...
($password, $salt) = @ARGV;
$password or die "usage: mycrypt password [salt]\n";
$salt = "cc" unless $salt;
$cryptpw = crypt($password,$salt);
This script will take your input and encrypt it. What it outputs is the encrypted version of whatever you input. Usage is like this. "./crypt_pass.pl password". What the script returns is an encrypted version of "password".
Now take the output and use it in another file... This file is called .htpasswd....
Where "yourusername" is whatever you used in the .htaccess file above and "cryptedoutput" is whatever crypt_pass.pl generated for you.
I really recommend searching for info about .htaccess and .htpasswd and see how other people suggest doing it. LIke I said, there are a lot of ways you can do this, and there are bound to be ways that are better or simpler for you.