Firstly sorry it took so long to answer this.
There are two ways you could solve this. If the passwords are stored in the file *.conf using the standard Unix DES-based encryption algorithm or MD5 you could use the crypt() function to encrypt the password, php notes on crypt here:
http://uk2.php.net/manual/en/function.crypt.php
Or you could use the exec() to use the encryption software and capture the result, php notes here:
http://uk2.php.net/manual/en/function.exec.php
One thing to note is the crypt function will use MD5 encryption if its on the system, look at the notes to work out how to call explictily.
After that the rest is simple file manipulation!
Hope this helps!