There is really no need to use someone else's implementation unless you need to share the auth with another application. If you have full control of the app, a good way to do it is to use sha1 digests with a salt. such as:
use strict;
use Digest::SHA1;
my $plaintext="Test1ng";
#generate a two char salt...
my $salts= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345
+6789./";
my $s1 = rand(64);
my $s2 = rand(64);
my $salt = substr($salts,$s1,1) . substr($salts,$s2,1);
my $sha1 = Digest::SHA1->new;
$sha1->add($salt.$plaintext);
# the enc pass is presented with the plaintext salt as the first two c
+hars.
my $encpass = $salt. $sha1->hexdigest;
print "$encpass\n";
This outputs:
kcc68a68507e8636a1a9a6badc059342b19a12c58e
And to test the password:
use strict;
use Digest::SHA1;
my $storedpass='kcc68a68507e8636a1a9a6badc059342b19a12c58e';
my $plaintext="Test1ng";
#pull salt from the saved password so you can compair...
my $salt = substr($storedpass,0,2) ;
my $sha1 = Digest::SHA1->new;
$sha1->add($salt.$plaintext);
# the enc pass is presented with the plain-text salt as the first two
+chars.
my $encpass = $salt. $sha1->hexdigest;
print "if $encpass = $storedpass the password is correct...\n";
which outputs:
perl testpass.pl
if kcc68a68507e8636a1a9a6badc059342b19a12c58e = kcc68a68507e8636a1a9a6
+badc059342b19a12c58e the password is correct...
The reason you "salt" the plain-text is so that if you have 30,000 users in the password database and you want to check to see if any use the password "greatwork" you have to digest it against up to 30,000 salts instead of just just digesting it once and moving on to the next word in the attack. Adding more than 2 random chars to a salt potentially adds more difficulty as you have more users in the database, as there would be less salt overlap. I hope this makes sense...