We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Encrypt database parameters

Hi!

I'm working on a project and I have to store the database credentials encrypted and when the connection is going to happen I should decrypt (database name, database password) and create the connection.

How can I achive this using Phalcon? I found that it is possible to intercept database related events (before/after query) but nothing like "before connection".

Can someone help me with this? Thank you!

edited Oct '16

I don't really see a point doing this. Why you need this exactly ? If you really need this then decrypt values from ini or whatever when creating db object.

As @Wojciech said why? If someone has access to your files he will be able to see the password anyway, even if you encrypted it. What is your actual idea so we may have better solution? Where do you want to store your credentials?



85.5k

using phalcon probably u cant, however if you want to over commit i suggest you write yourself an mysql plugin, then you can do whatever you want. including creating a token based on timestamp etc and encrypt decrypt what phalcon sends to the db