#!/usr/bin/perl use CGI::Carp 'fatalsToBrowser'; umask (011); require 'cgi-lib.pl'; # Change this next line to the path to your words.txt $unencrypted_pwords='/pfad/zur/textdatei.txt'; # Change this next line to the path to your .htpasswd file $htpasswd_FILE = '/pfad/zur/passwortdatei.pwd'; # Alte Passwortdatei löschen unlink ("$htpasswd_FILE"); # You shouldn't have to modify anything below this unless you know what you're doing. $salt1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; print &PrintHeader; open(PREAD,"<$unencrypted_pwords") ||&CgiError('Could not open unencrypted password file'); while () { chop $_; ($user,$pass) = split(/\:/,$_); $words{$user}=$pass; } close (PREAD); open(HTPASS,">>$htpasswd_FILE") || &error('Could not find specified file'); $number = 0; foreach $key (keys %words) { $salt = substr($salt1,rand(length($salt1)),1); $salt .= substr($salt1,rand(length($salt1)),1); $pass=$words{$key}; $encryptedpass = crypt ($pass,$salt); print HTPASS "$key:$encryptedpass\n"; $words{$key}=$encryptedpass; ++$number; } close(HTPASS); print "

Fertig! $number Benutzernamen und Passwörter wurden in die Datei $htpasswd_FILE geschrieben.

"; foreach $key (keys %words) { print "$key : $words{$key}
\n"; }