Perl SQL connection string needs to be encrypted

IT security people are asking me to not have unencrypted username/passwords on disk any longer. But I use several DSN files and need to be able to indicate what connection string to use. Is there a way to connect to a SQL database using the .NET encrypted version of a connection string? Or are there other means to handle this?

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You could patch the DBD module to allow an encrypted string. This may or may not be easy.

You could store the encrypted string in the code in a variable and then unencrypt it in code before using it as the connection string. If anyone knows how to read the code then they could get the unencrypted string but at least it's not stored on disk in unencrypted form.

Odd. It looks like you're using Win32::OLE to establish an ADODB connection. Is there some reason why you're not using DBD::ADO (via DBI) to establish an ADODB connection? That would be the much more normal way.

with the $dsn being the connection string you provide minus the user and password clauses (though it might work even with those embedded in the string rather than separated out).

Then again, that's really a tangent as it doesn't fix the encrypted connection string issue...

Another option that you could use is to have the username and password stored outside of the code and read in by the code. It could be stored in another database or in a file or something else (and could be encrypted and decoded by your code before being used to connect).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Storing the username and password elsewhere was my workaround too. Thanks for confirming that this is the best option here.

By the way: another option is to use integrated authentication in SQL, which does present the drawback that the account that is running the perlscript should be a SQL user too. In our case that is not OK, so I will go with your suggestion.