ASP.NET
  Home arrow ASP.NET arrow Encoding the Connection String
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Encoding the Connection String
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 12
    2005-12-21

    Table of Contents:
  • Encoding the Connection String
  • Simple code to encode and decode
  • Code for encoding and decoding
  • SQL Connection String in configuration file
  • Example of usage

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Encoding the Connection String


    (Page 1 of 5 )

    String connection information is used while connecting to databases, and sometimes stored in a web.config file. If that file is in clear text, it represents a security risk for the database. This article describes a simple way to encode that text to help keep the information out of dangerous hands.

    Introduction

    Examples of storing connection information while connecting to databases were shown in a previous tutorial, available here. The connection string information was stored in a web.config file.  However the string was stored in an easily readable XML file in clear text. All that is needed to hack a database would be available if one were to get access to the web.config file. It is essential therefore to make it harder to read this file to protect against such an eventuality. This tutorial discusses one method of obfuscating this information from prying eyes. However it is not infallible.

    Base64 Encoding

    Base64 encoding is a method of converting a piece of text (string) which can be read and comprehended into a string which looks as if it has been worked over (messed up). However, it can be carefully formatted back into a readable form with enough time. The process of decoding is the reverse of this process.

    Visual Studio .NET with its System.Text.ASCIIEncoding class gives us a convenient way to encode and decode strings. The ConnectionString which contains all the information about connecting to a database is contained in a string; therefore, the class methods can be used to encode and decode. This next picture shows an object browser displaying the details of the System.Text.ASCIIEncoding class.

    More ASP.NET Articles
    More By Jayaram Krishnaswamy


       · Encoding the connection string and placing it in the web config file with the server...
     

    ASP.NET ARTICLES

    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ
    - Developing a Dice Game Using ASP.NET Futures...
    - Completing an ASP.NET AJAX Server-Centric Ba...
    - Information Management for an ASP.NET AJAX S...
    - Comment and Order Management for an ASP.NET ...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT