Encrypt Passwords Perl Script

From LinuxServerTech

Jump to: navigation, search


Quick and Dirty Perl Script to encrypt a list of passwords

It expects the list of usernames and passwords to be sperated by : and to be piped to stdin. Problems might occur, when a username contains : (in the password, there shouldn't be a problem) Perl

#!/usr/bin/perl
while (<>) {
($username, $password)=split /:/, $_, 2;
chomp($password);
system("/usr/bin/htpasswd", "-b", "/path/to/htaccess", $username, $password);
}