Archive for February, 2013
I was forced to write a htpasswd utility in Perl 5 out of frustration. Neither nginx nor squid provide one and I’m not going to install Apache tools just to get such basic functionality. I was also dissatisfied with this one as it doesn’t do MD5 passwords, doesn’t handle spaces in passwords and the CLI is completely useless. You can get it here. It aims to behave as closely as possible to the original htpasswd utility in Apache. One needs to at least install Apache::Htpasswd and Term::ReadKey in order to run it. In fact the latter is only required for interactive mode. If you also want SHA1 hashes, then you need Digest::SHA and MIME::Base64 installed. SHA1 and plain text hashes are only implemented in output only mode. I should have probably used Authen::Htpasswd instead, as it supports file based operations with these hashes out of the box. This is left for a future revision or as an exercise to the user.
Update 03/03: Rewritten with Authen::Htpasswd. The script also got smaller while doing more.