bernhardrusch bernhardrusch - 3 months ago 13x
Python Question

Hiding a password in a (python) script

I have got a python script which is creating an ODBC connection. The ODBC connection is generated with a connection string. In this connection string I have to include the username and password for this connection.

Is there an easy way to obscure this password in the file (just that nobody can read the password when I'm editing the file) ?


Base64 encoding is in the standard library and will do to stop shoulder surfers:

>>> import base64
>>> print base64.b64encode("password")
>>> print base64.b64decode("cGFzc3dvcmQ=")