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. Web Development
  3. ASP.NET
  4. problem while using md5 for password encryption

problem while using md5 for password encryption

Scheduled Pinned Locked Moved ASP.NET
databasequestionhtmlsecurityhelp
7 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.
  • K Offline
    K Offline
    Kissy16
    wrote on last edited by
    #1

    hai all, i am using the below function for password encryption.here my password is changing into encrypted form,but i dont know how to check that encrypted form password with plain text password from database? because database contains plain text password.Please can anybody respond my question. i wanted to use md5 in my login page. I dont know exactly how to use it. Public Function MD5Encryption(ByVal passwd As String) As Byte Dim i As Integer Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider Dim hashedbytes As Byte() Dim textencoder As UTF8Encoding = New UTF8Encoding hashedbytes = md5.ComputeHash(textencoder.GetBytes(passwd)) md5.ComputeHash(textencoder.GetBytes(passwd)) Dim right As StringBuilder = New StringBuilder For i = 0 To hashedbytes.Length - 1 Step 1 right.Append(hashedbytes(i).ToString("x2")) Next i If (right.ToString() <> passwd) Then Response.Redirect("login.aspx") md5.Clear() Else Response.Redirect("index.html") End If End Function

    kissy

    S D 2 Replies Last reply
    0
    • K Kissy16

      hai all, i am using the below function for password encryption.here my password is changing into encrypted form,but i dont know how to check that encrypted form password with plain text password from database? because database contains plain text password.Please can anybody respond my question. i wanted to use md5 in my login page. I dont know exactly how to use it. Public Function MD5Encryption(ByVal passwd As String) As Byte Dim i As Integer Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider Dim hashedbytes As Byte() Dim textencoder As UTF8Encoding = New UTF8Encoding hashedbytes = md5.ComputeHash(textencoder.GetBytes(passwd)) md5.ComputeHash(textencoder.GetBytes(passwd)) Dim right As StringBuilder = New StringBuilder For i = 0 To hashedbytes.Length - 1 Step 1 right.Append(hashedbytes(i).ToString("x2")) Next i If (right.ToString() <> passwd) Then Response.Redirect("login.aspx") md5.Clear() Else Response.Redirect("index.html") End If End Function

      kissy

      S Offline
      S Offline
      ScottM1
      wrote on last edited by
      #2

      What exactly are you trying to do? Why would you want to encrypt it and then compare it to an unencrypted password stored in the database as plain text? If you are going to do this then the passwords that are stored in the database will need to be encrypted too. SQL 2005 has built in encryption:http://www.sqlservercentral.com/articles/SQL+Server+2005+-+Security/sql2005symmetricencryption/2291/[^]

      K 1 Reply Last reply
      0
      • S ScottM1

        What exactly are you trying to do? Why would you want to encrypt it and then compare it to an unencrypted password stored in the database as plain text? If you are going to do this then the passwords that are stored in the database will need to be encrypted too. SQL 2005 has built in encryption:http://www.sqlservercentral.com/articles/SQL+Server+2005+-+Security/sql2005symmetricencryption/2291/[^]

        K Offline
        K Offline
        Kissy16
        wrote on last edited by
        #3

        thanks for ur reply.exactly u r correct.If stored the password in encrypted form in the database can anybody know whats the password is? if some use asking his forgotten password,then how can i tell immediately if i look at the databse. For security purpose i wanted to encrypt,but the concept of storing encrypted password in the databse may lead to some other problem? Pleas understand my question and answer me. Thans once again

        kissy

        C S 2 Replies Last reply
        0
        • K Kissy16

          thanks for ur reply.exactly u r correct.If stored the password in encrypted form in the database can anybody know whats the password is? if some use asking his forgotten password,then how can i tell immediately if i look at the databse. For security purpose i wanted to encrypt,but the concept of storing encrypted password in the databse may lead to some other problem? Pleas understand my question and answer me. Thans once again

          kissy

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

          Kissy16 wrote:

          .If stored the password in encrypted form in the database can anybody know whats the password is?

          You have some major issues. 1 - MD5 is a hash, NOT an encryption. Therefore, you have to apply MD5 to your entered password and see if the hashes match. 2 - MD5 is not very secure at all. It's better than plaintext, but not much good against a serious attacker. Your best bet is to add some salt, and hope they can't work out what that is

          Kissy16 wrote:

          but the concept of storing encrypted password in the databse may lead to some other problem?

          The concept of storing your non encrypted password leads to the problem you're trying to avoid. No two ways about it. Try thinking this through, just a little.

          Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

          1 Reply Last reply
          0
          • K Kissy16

            thanks for ur reply.exactly u r correct.If stored the password in encrypted form in the database can anybody know whats the password is? if some use asking his forgotten password,then how can i tell immediately if i look at the databse. For security purpose i wanted to encrypt,but the concept of storing encrypted password in the databse may lead to some other problem? Pleas understand my question and answer me. Thans once again

            kissy

            S Offline
            S Offline
            ScottM1
            wrote on last edited by
            #5

            How important is it that these passwords remain protected? Just remember that if somebody has access to your passwords within your database then they probably have access to all your other data too which makes it kinda pointless encrypting all your passwords.

            K 1 Reply Last reply
            0
            • S ScottM1

              How important is it that these passwords remain protected? Just remember that if somebody has access to your passwords within your database then they probably have access to all your other data too which makes it kinda pointless encrypting all your passwords.

              K Offline
              K Offline
              Kissy16
              wrote on last edited by
              #6

              thanks once again yes u r correct, 1)but the use may change his password in later.At that time is that sqlserver automatically convert the changed password into encrypt form. 2)No this time how do i know what user has changed? This is my question,i have no idea please guide me through ur knowedge. So please tell me the answer

              kissy

              1 Reply Last reply
              0
              • K Kissy16

                hai all, i am using the below function for password encryption.here my password is changing into encrypted form,but i dont know how to check that encrypted form password with plain text password from database? because database contains plain text password.Please can anybody respond my question. i wanted to use md5 in my login page. I dont know exactly how to use it. Public Function MD5Encryption(ByVal passwd As String) As Byte Dim i As Integer Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider Dim hashedbytes As Byte() Dim textencoder As UTF8Encoding = New UTF8Encoding hashedbytes = md5.ComputeHash(textencoder.GetBytes(passwd)) md5.ComputeHash(textencoder.GetBytes(passwd)) Dim right As StringBuilder = New StringBuilder For i = 0 To hashedbytes.Length - 1 Step 1 right.Append(hashedbytes(i).ToString("x2")) Next i If (right.ToString() <> passwd) Then Response.Redirect("login.aspx") md5.Clear() Else Response.Redirect("index.html") End If End Function

                kissy

                D Offline
                D Offline
                dwaipayan9
                wrote on last edited by
                #7

                hi..i m facing most of the same problem as u. my problem is that, i've taken any random number and encrypt it through md5 and store it in the database.. but while changing password, when i want to check that random number with that encrypted password(i've encrypted the random number) then the encryption of the random number is not same as that one which is stored in database. while checking, i m giving the random number through text box. i think(with my a bit knowledge), encryption of value of a variable will not be same as encryption of the same value entered by the textbox. it can be some database problem also....i dont know.... i m sure that my coding is correct

                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