Jasypt equivalent for Python

135 Views Asked by At

I'm trying to write a python application that must connect to a Postgres database.

I'm trying to use psycopg2 for this. Here's my connection:

connection = psycopg2.connect(user="username",
    password="password",
    host="1.6.2.1",
    port="5432",
    database="mydatabase",
    sslmode='require')

My problem is that I can't save the password in my code or in any kind of properties file or anywhere else that someone could view it.

As a Java developer, I'm used to using Jasypt and saving an encrypted password string in my application.properties. The entry looks like this:

spring.datasource.password=ENC(udfrtIm1ypnfWTTOb29mt2IzvTTZsgwi)

Is there any way I can use this particular string in my Python application or do something similar in Python?

0

There are 0 best solutions below