If you need to read the password back, do encryption at the Database layer rather than the application layer - just ensure that you're connecting to the database either locally or over SSL.
To store the password the steps would be something like:
- Computer >>
- HTTPS >>
- Web server (PHP form) >>
- (HTTPS if on a different server >>)
- database (AES Encryption)
Depending on the database you're using the syntax will probably change, but with MySQL you can do something like:
INSERT INTO `table` (`password`)
VALUES (AES_ENCRYPT('{$sPassword}', '{$sEncryptionKey}'))
Since PHP is writing this to the database you can use a PDO prepared statement to get the data in there...
To retrieve the password with your Python script you'll simply need to run a SELECT statement on the SQL server with something like (assuming the data is in an AES encrypted BLOB) this:
SELECT CONVERT(AES_DECRYPT(`table`.`password`, '{$sEncryptionKey}') USING 'utf8')
AS `password`
This way the only common data you need between PHP and Python is the encryption key (which is just a string). As long as you maintain an SSL connection whenever you're passing this data across the Internet, you should be OK.