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. best approach for storing login info

best approach for storing login info

Scheduled Pinned Locked Moved C#
questiondatabasesysadminxmljson
5 Posts 5 Posters 1 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.
  • Z Offline
    Z Offline
    zuhx
    wrote on last edited by
    #1

    I have an application that connects to a database where the user has to log in to access the app. The login screen is the first screen the user encounters and requires the user to enter username/psswd info along with database info (i.e. database name, server name, etc...). I want to set it up so that when the app is run it will pull up the info entered by the user from the last time. What is the best way to approach this? I thought of XML serialization, but as I understand it, this is not a secure method and therefore passwd info should not be stored in passwd file. I already make a database connection in this form, so if I could I would like to store this data in the database, but I cannot make the connection string until the user enters that info. I suppose I could do the mix of the two, but how will that affect performance? Any one have thoughts. Thanks in advance.

    O R 2 Replies Last reply
    0
    • Z zuhx

      I have an application that connects to a database where the user has to log in to access the app. The login screen is the first screen the user encounters and requires the user to enter username/psswd info along with database info (i.e. database name, server name, etc...). I want to set it up so that when the app is run it will pull up the info entered by the user from the last time. What is the best way to approach this? I thought of XML serialization, but as I understand it, this is not a secure method and therefore passwd info should not be stored in passwd file. I already make a database connection in this form, so if I could I would like to store this data in the database, but I cannot make the connection string until the user enters that info. I suppose I could do the mix of the two, but how will that affect performance? Any one have thoughts. Thanks in advance.

      O Offline
      O Offline
      obelisk29
      wrote on last edited by
      #2

      Why don't you just write it to the registry using an Encryption algorithm?

      H 1 Reply Last reply
      0
      • O obelisk29

        Why don't you just write it to the registry using an Encryption algorithm?

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        Using the registry is not recommended for .NET applications. Instead (to the original poster) you can still encrypt the password and save it to the .config file (named yourappname.exe.config) either in the <appSettings> or to your own section that you can create using an implementation of IConfigurationSectionHandler. Using .config files is far more robust for .NET apps because it centralizes application settings. The idea would still be the same, though, and there's many ways to accomplish the task.

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        1 Reply Last reply
        0
        • Z zuhx

          I have an application that connects to a database where the user has to log in to access the app. The login screen is the first screen the user encounters and requires the user to enter username/psswd info along with database info (i.e. database name, server name, etc...). I want to set it up so that when the app is run it will pull up the info entered by the user from the last time. What is the best way to approach this? I thought of XML serialization, but as I understand it, this is not a secure method and therefore passwd info should not be stored in passwd file. I already make a database connection in this form, so if I could I would like to store this data in the database, but I cannot make the connection string until the user enters that info. I suppose I could do the mix of the two, but how will that affect performance? Any one have thoughts. Thanks in advance.

          R Offline
          R Offline
          Rein Hillmann
          wrote on last edited by
          #4

          Storing (and ESPECIALLY retrieving) a password is never secure. Why would you want to retrieve the password from a file? You should never have to retrieve a password, it should always be given to you by the user.

          K 1 Reply Last reply
          0
          • R Rein Hillmann

            Storing (and ESPECIALLY retrieving) a password is never secure. Why would you want to retrieve the password from a file? You should never have to retrieve a password, it should always be given to you by the user.

            K Offline
            K Offline
            Kentamanos
            wrote on last edited by
            #5

            I'm not a security expert, but there's one thing I've picked up... In general, you should never store a password. I think it's a bad idea to even store an encrypted one. If you store an encrypted one and your keys are compromised, decrypting it is trivial. Store the hash of a password and "salt" that hash. It's preferable to have your salt have something in it that varies per user. Assuming the user-list and password hash is compromised, salting prevents a hacker from gaining easy entry. Having your salt have something unique per user in it prevents comparing a known account with a known password and finding another account with that same password. Then hash what they input and check it against the stored hash. Do a search for hash's and salt for some more info.


            I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
            -David St. Hubbins

            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