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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Encryption

Encryption

Scheduled Pinned Locked Moved C#
databasesql-serversysadminsecuritytutorial
6 Posts 4 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
    sangramkp
    wrote on last edited by
    #1

    Hi I am working on a windows Application. I want to store the Passwords in SQL server 2005 in encrypted format. How to do this? And Again how to validate the credentials with an user input

    T C V 3 Replies Last reply
    0
    • S sangramkp

      Hi I am working on a windows Application. I want to store the Passwords in SQL server 2005 in encrypted format. How to do this? And Again how to validate the credentials with an user input

      T Offline
      T Offline
      Talal Sultan
      wrote on last edited by
      #2

      If you do not need to retrieve the password that was stored, you can use a hash version of it. When a user enters his username and password in your application, you would hash the password and compare it to the hash that you have in the database to see if it matches. If you need to have a way to retrieve the password, you cannot use hash, you need to apply an encryption algorithm to be able to decryt it later. Talal

      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook

      S 1 Reply Last reply
      0
      • T Talal Sultan

        If you do not need to retrieve the password that was stored, you can use a hash version of it. When a user enters his username and password in your application, you would hash the password and compare it to the hash that you have in the database to see if it matches. If you need to have a way to retrieve the password, you cannot use hash, you need to apply an encryption algorithm to be able to decryt it later. Talal

        "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook

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

        Thanks for reply Can you just send me a sample of hashing.:rose:

        T 1 Reply Last reply
        0
        • S sangramkp

          Hi I am working on a windows Application. I want to store the Passwords in SQL server 2005 in encrypted format. How to do this? And Again how to validate the credentials with an user input

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Typically, you'd use the Cryptography namespace, pick an algorithm, salt your password and pass a hash into SQL Server. Then you'd pass the user input, also salted and hashed, to a stored proc that returns if the username/password combination is valid

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          1 Reply Last reply
          0
          • S sangramkp

            Thanks for reply Can you just send me a sample of hashing.:rose:

            T Offline
            T Offline
            Talal Sultan
            wrote on last edited by
            #5

            You have two types of hashes you can do, MD5 or SHA1. The following method gives you a SHA1 hash string of the string it receives.

            public string CreateSHA1PasswordHash(string inputString)
            {
            SHA1 sha1 = new SHA1CryptoServiceProvider();
            byte[] buffer = Encoding.UTF8.GetBytes(inputString);
            byte[] cipher = sha1.ComputeHash(buffer);
            StringBuilder sb = new StringBuilder(cipher.Length * 2);
            for (int i=0; i<cipher.Length; i++)
            sb.Append(cipher[i].ToString("x2"));
            return sb.ToString();
            }

            Hope this helps. Talal

            "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook

            1 Reply Last reply
            0
            • S sangramkp

              Hi I am working on a windows Application. I want to store the Passwords in SQL server 2005 in encrypted format. How to do this? And Again how to validate the credentials with an user input

              V Offline
              V Offline
              Vasudevan Deepak Kumar
              wrote on last edited by
              #6

              You may also like to check out this library: http://www.codeproject.com/dotnet/xcrypt.asp[^]

              Vasudevan Deepak Kumar Personal Homepage Tech Gossips

              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