I need to leave an encrypted connection string and still be able to read it
User Id=*******;Password=*****;Data Source=(DESCRIPTION=((ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP )(HOST = *********)(PORT=****)))(CONNECT_DATA=(SERVICE_NAME=********)))
and I'm not using web.config, I'm using program.cs because I'm doing it in .NET 6.
Is there a way to encrypt or leave it in a safer way than leaving this variable private?
At the moment I'm doing it like this in the program.cs:
var stringConexao = "User Id=*******;Password=*****;Data Source=(DESCRIPTION=((ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST = *********)(PORT=****)))(CONNECT_DATA=(SERVICE_NAME=********)))";
And in the function where I make the queries:
private readonly string connectionString = "User Id=*******;Password=*****;Data Source=(DESCRIPTION=((ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST = *********)(PORT=****)))(CONNECT_DATA=(SERVICE_NAME=********)))";