how to decrypt MD5 function in mysql syntax

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vishal prada
    New Member
    • Mar 2012
    • 52

    how to decrypt MD5 function in mysql syntax

    i used MD5 function to encrypt password ..
    Code:
    PreparedStatement pstmt=con.prepareStatement("insert into regist values(?,MD5(?),MD5(?),?,?,?,?,?,?,?,?,?,?,?,?)");
    
    		pstmt.setString(1,vEmailId);
    		pstmt.setString(2,vPassword);
    		pstmt.setString(3,vConfirmPassword);
    but i want to Decrypt that password for login condition where it is not match the same password.
    what to do.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    MD5 is a hashing algorithm not an encryption one. Read here for how to use hashing algorithms and prefer SHA2 https://www.owasp.org/index.php/Hashing_Java

    Comment

    • vishal prada
      New Member
      • Mar 2012
      • 52

      #3
      but how to decrypt sha encryption
      as us suggest i use sha1 but how to reverse it in plan text for login to compare that encrypted password.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        You don't. Hashing algorithms are not reversible.
        You never need to decrypt passwords.
        When a user logs in just calculate the hash again and compare the hash with what's on the database. No need to get the password from the hash.

        Comment

        • vishal prada
          New Member
          • Mar 2012
          • 52

          #5
          THEN how could i retrieve password .
          becoz i am match that password during login and becoz of encryption it can't match , condition always false.
          what to do to protect password other than this.

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            It should match.
            Here is how it works.

            When a new user comes in with their password calculate the hash for that password and store the hash in the database against that user name (also store a salt for it).

            When a user wants to log in, take their entered password and use the same algorithm to calculate it's hash and it's salt. Then check the database to see if that hash and salt is against that user in the database. There is on encryption/decryption involved here. Just calculating hashes.

            Comment

            • vishal prada
              New Member
              • Mar 2012
              • 52

              #7
              any pages to read this becoz whatever u said
              i got that but i want to visualize that all whatever u explain
              me. plz tell me.

              Comment

              • vishal prada
                New Member
                • Mar 2012
                • 52

                #8
                MySQL AES functions (AES_ENCRYPT() and AES_DECRYPT())

                do u know this how to use this.

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Yes. But that is not a hashing algorithm. AES and DES are are encryption algorithms and are the ones where you encrypt/decrypt values.
                  MD5 and SHA are hashing algorithms and when you use those you just calculate hashes and compare the hashes. They are perfect for passwords because there is never a need to compute a user's password.

                  Comment

                  • vishal prada
                    New Member
                    • Mar 2012
                    • 52

                    #10
                    then plz tell me how to use that.

                    Comment

                    • r035198x
                      MVP
                      • Sep 2006
                      • 13225

                      #11
                      Which one? SHA2 is explained in detail in that link I posted. They even have complete Java source code showing how to use it.

                      AES in MySQL is explained in detail in the refmanual:http://dev.mysql.com/doc/refman/5.5/...on_aes-decrypt

                      Comment

                      • Rabbit
                        Recognized Expert MVP
                        • Jan 2007
                        • 12517

                        #12
                        You shouldn't use a reversible encryption like AES to store passwords. Use the hash, everyone uses the hash. There is absolutely no need to ever need to retrieve the original password that was used to create the hash.

                        Comment

                        Working...