On Mon, 11 Feb 2002 14:06:27 +0100 "Martin.Andrew" <[EMAIL PROTECTED]> wrote:
> Does anyone know how to encrypt a password for use in htaccess? > > I creating a secure environment using PHP, I create the directory structure > and htaccess files dynamically based on php forms / sessions but I'm having > problems encrypting the password for the htpasswd file for apache. > > I have see many examples but most seem to be perl scripts which I don't want > to use! > Can it be done with PHP? Maybe you can use the "exec" function to execute the htpasswd.exe utility that comes with Apache for Windows. $path_to_htpwd = "\"C:\\Program Files\\Apache Group\\Apache\\Bin\\htpasswd.exe\""; exec(getenv("COMSPEC")." /c $path_to_htpwd -c -b $filename $username $password"); Note that the "-c" flag will create a new file or overwrite an existing one. If you want to append new usernames and passwords to an already existing file, remove the "-c" flag. I tested it on my machine and it worked. Cheers, Rubén Gutiérrez -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php