We help IT Professionals succeed at work.

encrypt username and password in perl script

jeffreyjseaman
on
Hi,

I am not familiar with perl to much. I am able to connect to the database with the perl script.
However the username and password is shown in the perl script.

I want to use the ODBC String that will connect to the ODBC setup on the windows server.
How do I do this in the code?

Thanks
if(!($db=new Win32::ODBC("DSN=database;uid=user;pwd=password"))) {
print "error connecting to the database";
exit(8);
}

Open in new window

Comment
Watch Question

Commented:
I'm not sure if it's possible to send an encrypted password like that.  If you give enough information to make the connection, then anyone with access to your code could send that same information from another program and make the same connection.

However, you did not specify which database you are connecting to.  If your database supports it, you may be able to set up a database account that can only connect from this one server where you are running this perl script and then the username and password do the user no good unless they already have access to your server where you are running the perl.

The other thing I can think of would be to store the username and password in a file which you can put in a secure directory (e.g. if you're concerned about people looking at your code repository and thereby learning the password, you can exclude the file from the repository).

Do these ideas help at all?

Author

Commented:
Thanks, I will reward you the points for helping out. This is my resolution.

I provided the windows NT user access to the database. I then setup a ODBC connection to the database with the NT Username.

Then I setup the connection to be the following;

if(!($db=new Win32::ODBC("DSN=ODBCName;;))) {
print "error connecting to the database";
exit(8);
}

That works.

Thanks