in reply to Using htaccess & htpasswd for password protection
The crypt() function in Perl is a variation of a DES (Data Encryption Standard) hash algorithm. This function is similar to the c crypt() function.
char *crypt(const char *key, const char *salt);
Perl's crypt() function should work for what you are trying to do. You can't do your own encryption algorithm since it isn't really encryption, it is a hash. If you can't get the perl crypt to work, you can try to snatch the c version from libc source, and use it in your script, it is very portable.