Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. protect my database connection string

protect my database connection string

Scheduled Pinned Locked Moved C#
questiondatabase
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sasuko
    wrote on last edited by
    #1

    how can i protect my string: provate string conn_string = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "mydatabase.mdb" + ";Jet OLEDB:Database Password=mypassword;"; in this way everyone can get "mypassword" so how can i protect it?

    G O L 3 Replies Last reply
    0
    • S Sasuko

      how can i protect my string: provate string conn_string = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "mydatabase.mdb" + ";Jet OLEDB:Database Password=mypassword;"; in this way everyone can get "mypassword" so how can i protect it?

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Not everyone, unless you put that in a publically available file. Then the solution would obviously be not to. From whom do you need to protect it? --- b { font-weight: normal; }

      S T 2 Replies Last reply
      0
      • G Guffa

        Not everyone, unless you put that in a publically available file. Then the solution would obviously be not to. From whom do you need to protect it? --- b { font-weight: normal; }

        S Offline
        S Offline
        Sasuko
        wrote on last edited by
        #3

        it is very easy to hacker a c# compiled source. so it is very easy to get a password to get access at the database.

        1 Reply Last reply
        0
        • S Sasuko

          how can i protect my string: provate string conn_string = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "mydatabase.mdb" + ";Jet OLEDB:Database Password=mypassword;"; in this way everyone can get "mypassword" so how can i protect it?

          O Offline
          O Offline
          OldDog Net
          wrote on last edited by
          #4

          You put your connection string in your configuration file and you encrypt it. You of course have to decrypt it to use it. Take a look at Microsoft's Enterprise Library in their "Patterns and Practices" stuff. The Enterprise Library includes "Application Blocks" for Encryption, Configuration, Database Access, Logging, Exceptions, and more I think. It's huge but there's a lot of good stuff in there if you choose to use it. Also, there's a property (sorry I don't remember the name) on the Connection objects that directs it not to store sensitive info. This is only the password in Oracle's ODP.Net but I think SQL Server's Connection is supposed to drop the Id as well. I don't know about OLEDB. Good luck.

          1 Reply Last reply
          0
          • S Sasuko

            how can i protect my string: provate string conn_string = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "mydatabase.mdb" + ";Jet OLEDB:Database Password=mypassword;"; in this way everyone can get "mypassword" so how can i protect it?

            L Offline
            L Offline
            LongRange Shooter
            wrote on last edited by
            #5

            What we would do is the following: 1) put the connection string in a config file 2) encapsulate getting the string from the config file 3) once you are successful in getting the read from db working in a test configuration, add an encryption module. 4) write a quick and dirty that encrypts any string and shows the result 5) use your encryption technique and encrypt the string 6) replace your connection string with the encrypted data 7) add the decryption in your encapsulated routine and verify you can still access the database 8) now place the encryption/decryption key in the registry and lock it down with security so that only your application has the rights to read it. There are 10 kinds of people in the world.
            Those that read binary...
            ...and those who don't.

            S 1 Reply Last reply
            0
            • G Guffa

              Not everyone, unless you put that in a publically available file. Then the solution would obviously be not to. From whom do you need to protect it? --- b { font-weight: normal; }

              T Offline
              T Offline
              tarasn
              wrote on last edited by
              #6

              This How To shows you how to create a managed class library that exposes DPAPI functionality to applications that want to encrypt data, for example, database connection strings and account credentials. DevIntelligence.com - My blog for .Net Developers

              1 Reply Last reply
              0
              • L LongRange Shooter

                What we would do is the following: 1) put the connection string in a config file 2) encapsulate getting the string from the config file 3) once you are successful in getting the read from db working in a test configuration, add an encryption module. 4) write a quick and dirty that encrypts any string and shows the result 5) use your encryption technique and encrypt the string 6) replace your connection string with the encrypted data 7) add the decryption in your encapsulated routine and verify you can still access the database 8) now place the encryption/decryption key in the registry and lock it down with security so that only your application has the rights to read it. There are 10 kinds of people in the world.
                Those that read binary...
                ...and those who don't.

                S Offline
                S Offline
                Sasuko
                wrote on last edited by
                #7
                1. now place the encryption/decryption key in the registry and lock it down with security so that only your application has the rights to read it. what do you mean about registry, and "lock it down with security.."?
                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups