4
# Utility which takes a username and password
5
# on the command line and generates a username
6
# sha1-encrytped password on the stdout.
9
# ./htpasswd-sha1.pl dirkx MySecret >> sha1-passwd
11
# This is public domain code. Do whatever you want with it.
12
# It was originally included in Clinton Wong's Apache 1.3.6 SHA1/ldif
13
# patch distribution as sample code for generating entries for
14
# Apache password files using SHA1.
16
use MIME::Base64; # http://www.cpan.org/modules/by-module/MIME/
17
use Digest::SHA1; # http://www.cpan.org/modules/by-module/MD5/
19
if ($#ARGV!=1) { die "Usage $0: user password\n" }
21
print $ARGV[0], ':{SHA}', encode_base64( Digest::SHA1::sha1($ARGV[1]) );