Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Don't Want to hard code password in the code? Is there any other way?

Status
Not open for further replies.

princessk1

Programmer
Feb 28, 2002
74
0
0
CA
I am using an ADO connection to connect to my database but I don't want to hardcode the password into the code. Is there any way to encrypt this password for security reasons? Thanks.
 
The only people who can see the password are those that have access to your ASP code. The general public can't see ASP code in the page so the only security risk is from your colleagues!

Not that I'm implying anything I'm just stating the obvious.

William
Software Engineer
ICQ No. 56047340
 
You could create a DLL where you create the connection to the DB. Or you could read the connection string from Registry. But this also only from DLL

 
The way I include my connection string into pages is by using Application level variables.
conn.Open(Application("ConnStr"),Application("Uname"),Application("Pwd"))

You can also use an include file in which you specify uname and pwd. You shouldn't hardcode it even if you don't care about security since then if the password or server address changes you have to make changes to all pages instead of just one.

Hope this helps <Dmitriy>
dbrom@crosswinds.net
 
If you are using NT Network, you could use Trusted Connection

cn1.Open &quot;Provider=SQLOLEDB;Data Source=MYDTSRCE;Trusted_Connection=Yes&quot;
 
Another option is to create a table just for passwords. Then secure the table. You could then read the table without having the password on the page. I did that for a lot of my pages.
 
If using ADO 2.5+ consider using a .UDL file for storing the connection information. This has the benefit of localizing the connection information to a single file, and is a supported, native, code-free solution that is easy to maintain (better than registry, better than pwds in a DB).

Once you have created a UDL file just use it in the ConnectionString of ADO:

cnPubs.ConnectionString = &quot;File Name=C:\Path\To\Pubs.udl;&quot;


The following link gives good details on creating .UDL files (be careful if the forum splits the link across multiple lines):

<LINK>


</LINK>

Enjoy,
Tom Rogers
TJRTech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top